Skip to content

Commit 2d11052

Browse files
committed
Automatically install systemd timers with Makefile
1 parent d7603c4 commit 2d11052

File tree

8 files changed

+18
-7
lines changed

8 files changed

+18
-7
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ install:
77
install src/zfs-auto-snapshot.8 $(DESTDIR)$(PREFIX)/share/man/man8/zfs-auto-snapshot.8
88
install -d $(DESTDIR)$(PREFIX)/sbin
99
install src/zfs-auto-snapshot.sh $(DESTDIR)$(PREFIX)/sbin/zfs-auto-snapshot
10+
install -d $(DESTDIR)/etc/systemd/system
11+
install timers/zfs-auto-daily.service $(DESTDIR)/etc/systemd/system/zfs-auto-daily.service
12+
install timers/zfs-auto-daily.timer $(DESTDIR)/etc/systemd/system/zfs-auto-daily.timer
13+
install timers/zfs-auto-hourly.service $(DESTDIR)/etc/systemd/system/zfs-auto-hourly.service
14+
install timers/zfs-auto-hourly.timer $(DESTDIR)/etc/systemd/system/zfs-auto-hourly.timer
15+
install timers/zfs-auto-weekly.service $(DESTDIR)/etc/systemd/system/zfs-auto-weekly.service
16+
install timers/zfs-auto-weekly.timer $(DESTDIR)/etc/systemd/system/zfs-auto-weekly.timer

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,27 @@ Scheduling:
2424
-------------
2525
I recommend scheduling this using [systemd timers](https://wiki.archlinux.org/index.php/Systemd/Timers).
2626

27-
You can find some example `.timer` files in the examples directory of this repo.
27+
You can find some example `.timer` files in the `timers/` directory of this repo. They will be installed when you run `make install`.
2828

29-
Copy the `.timer` and corresponding `.service` file to `/etc/systemd/system/`:
3029
```
31-
cp -f -v *.timer *.service /etc/systemd/system/
32-
```
33-
Then enable the timers as follows:
30+
You can enable the timers as follows:
3431
```
3532
sudo systemctl daemon-reload
3633
sudo systemctl start zfs-auto-hourly.timer && sudo systemctl enable zfs-auto-hourly.timer
3734
sudo systemctl start zfs-auto-daily.timer && sudo systemctl enable zfs-auto-daily.timer
3835
sudo systemctl start zfs-auto-weekly.timer && sudo systemctl enable zfs-auto-weekly.timer
3936
```
4037
38+
If you wish to edit the timers, you will find them in the `/etc/systemd/system/` directory.
39+
4140
4241
Managing Which Pools to Snapshot
4342
-------------
4443
By default, the script will snapshot all pools automatically, unless they have the `com.sun:auto-snapshot` property set to `false`.
4544
46-
To check whether a pool has this property set, run the following command (where `archive` is the pool name):
45+
To check the status of this property for all of your pools and datasets, run the following command:
4746
```
48-
sudo zfs get com.sun:auto-snapshot archive
47+
sudo zfs get com.sun:auto-snapshot
4948
```
5049
5150
If you see an output like the following, then snapshots are enabled on this pool:
@@ -64,3 +63,8 @@ We can check with `zfs get` again, and this time our output should look like the
6463
NAME PROPERTY VALUE SOURCE
6564
archive com.sun:auto-snapshot false local
6665
```
66+
67+
To disable snapshots on a single dataset, the command is very similar:
68+
```
69+
sudo zfs set com.sun:auto-snapshot=false archive/dataset
70+
```

0 commit comments

Comments
 (0)