Skip to content

Commit 9f5c966

Browse files
committed
Recommend systemd timers instead of cron
1 parent 0b42bf8 commit 9f5c966

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ that is compatible with [ZFS on Linux](http://zfsonlinux.org/).
55

66
My fork removes the automatic installation of cron entries that do things
77
the user may not desire. This fork only installs the script and leaves manual
8-
crontab configuration up to the user.
8+
crontab/systemd-timer configuration up to the user.
99

1010
This program is a posixly correct bourne shell script. It depends only on
11-
the zfs utilities and cron, and can run in the dash shell.
11+
the zfs utilities, and can run in the dash shell.
1212

1313

1414
Installation:
1515
-------------
1616
```
17-
wget https://github.com/ajhaydock/zfs-auto-snapshot/archive/master.zip
18-
unzip master.zip
19-
cd zfs-auto-snapshot-master
17+
git clone https://github.com/ajhaydock/zfs-auto-snapshot.git
18+
cd zfs-auto-snapshot
2019
sudo make install
2120
```
2221

2322

24-
Example Crontab Entries:
23+
Scheduling:
2524
-------------
26-
```
27-
## ZFS Auto Snapshot
25+
I recommend scheduling this using [systemd timers](https://wiki.archlinux.org/index.php/Systemd/Timers).
2826

29-
# At half past midnight every day, create a daily ZFS snapshot of 'archive'. Keep 7 of these.
30-
30 0 * * * /usr/local/sbin/zfs-auto-snapshot archive --recursive --quiet --syslog --prefix="auto" --label="daily" --keep=7
27+
You can find some example `.timer` files in the examples directory of this repo.
3128

32-
# At 1AM every Monday, create a weekly ZFS snapshot of 'archive'. Keep 4 of these.
33-
0 1 * * 1 /usr/local/sbin/zfs-auto-snapshot archive --recursive --quiet --syslog --prefix="auto" --label="weekly" --keep=4
29+
Copy the `.timer` and corresponding `.service` file to `/etc/systemd/system/`, and then enable the timers as follows:
30+
```
31+
sudo systemctl daemon-reload
32+
sudo systemctl enable zfs-auto-daily.timer
33+
sudo systemctl enable zfs-auto-weekly.timer
3434
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Unit]
2+
Description=Create a daily ZFS snapshot of archive. Keep 7 of these.
3+
4+
[Service]
5+
ExecStart=/usr/local/sbin/zfs-auto-snapshot archive --recursive --quiet --syslog --prefix="auto" --label="daily" --keep=7
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Daily ZFS snapshots.
3+
4+
[Timer]
5+
OnCalendar=daily
6+
7+
[Install]
8+
WantedBy=timers.target
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Unit]
2+
Description=Create a weekly ZFS snapshot of archive. Keep 4 of these.
3+
4+
[Service]
5+
ExecStart=/usr/local/sbin/zfs-auto-snapshot archive --recursive --quiet --syslog --prefix="auto" --label="weekly" --keep=4
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Weekly ZFS snapshots.
3+
4+
[Timer]
5+
OnCalendar=weekly
6+
7+
[Install]
8+
WantedBy=timers.target

0 commit comments

Comments
 (0)