[tek-nol-uh-jee]

Fast howto: Weekly backup of your home dir with systemd timers and duplicity

Disclaimer: “Fast howto” means in my world just dumping my config files for everyone to use, explanations are optional. 🙂

 

Hint: duplicity is very good in encrypting your backuped data, but my backup data disks are already encrypted through luks, so I’m not using this feature!

/etc/systemd/system/homeBackup.timer

[Unit]
Description=weekly full home directory backup

[Timer]
# see systemd.time(7) manual page for other scheduling options
OnCalendar=Sun
# run immediately if we missed a backup for some reason
Persistent=true
OnBootSec=15min
#OnUnitActiveSec=1w 

[Install]
WantedBy=timers.target

/etc/systemd/system/homeBackup.service

[Unit]
Description=full home backup

[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/root/homeBackup.sh

/root/homebackup.sh

#!/bin/bash

#backup to my NAS through NFS mount 
#(mounted at boot)
duplicity --no-encryption --asynchronous-upload --volsize 100 -v6 --exclude '**/*/.cache' --exclude '**/whatever/you/like'  /home file:///mnt/your/backup/path

Further hints:

#maybe a reload is needed
systemctl daemon-reload
#run manually (for testing maybe?)
systemctl start homeBackup.service
#enable timer
systemctl enable homeBackup.timer
#just enabling is not enough! 
#start the timer
systemctl start homeBackup.timer
#after start the first run starts immediately, after that at the specified time stamps with "OnCalendar"
#check all timers (with inactives, --all)
systemctl list-timers --all
#check backup log
journalctl -u homeBackup.service

Leave a Reply

Your email address will not be published. Required fields are marked *