Table of Contents
Backup
To start a daily backup at 23:03:
$ cat /etc/cron.d/client-backup
3 23 * * * root /opt/imlbackup/client/backup.sh >/dev/null 2>&1
… or with using the cronwrapper
see 📗 https://www.axel-hahn.de/docs/cronwrapper/ 🧾 https://github.com/axelhahn/cronwrapper
TTL is 1440 for 1440 min = 1d
$ cat /etc/cron.d/client-backup
3 23 * * * root /usr/local/bin/cronwrapper.sh 1440 /opt/imlbackup/client/backup.sh 'iml-backup'
Prune and verify
By default prune and verify are executed on each backup run. This is a safe way. A very safe way.
BUT: By doing this the backup with Restic is running for a few seconds and prune + verify take a much-much longer time. In many cases it is a good idea to split backup and prune + verify.
Example:
You want to start a daily (or hourly) backup. Pruning and verify shall run on Saturday and Sunday.
In jobs/transfer.job set a limit greater 7 days:
prune-after = 14
verify-after = 14
Then define your weekly yobs on Saturday and Sunday.
$ cat /etc/cron.d/client-backup
3 23 * * * root /usr/local/bin/cronwrapper.sh 1440 /opt/imlbackup/client/backup.sh 'iml-backup'
7 18 * * 6 root /usr/local/bin/cronwrapper.sh 1440 /opt/imlbackup/client/prune.sh 'iml-backup-prune'
7 18 * * 0 root /usr/local/bin/cronwrapper.sh 1440 /opt/imlbackup/client/verify.sh 'iml-backup-verify'
Desktop notification
If you don’t run the backup on a server but on a client you can activate the desktop notification for a user that is logged in. It uses notify-send to show notification messages.
In a cronjob that start the backup script as root must know the user that should get the notifications.
Set a variable SUDO_USER=<USERNAME>
in your cron file.
Example:
$ cat /etc/cron.d/client-backup
SUDO_USER=axel
17 * * * * root /usr/local/bin/cronwrapper.sh 1440 /opt/imlbackup/client/backup.sh 'iml-backup'