{{tag>systemd backup}}
====== systemd rsync service ======
///etc/systemd/system/rsync-backup.service//:
[Unit]
Description=Copy home folder to HD on shutdown
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/home/user/.rsync-to-HD.sh
[Install]
WantedBy=multi-user.target
rsync-to-HD.sh
#!/bin/bash
rsync -avP --include-from='.rsync-include.txt' /home/user/ /media/user/BAckup/user/
rsync-include.txt
# include only files in rhythmbox folder (and the folder itself -> 3 "***")
+ .local/
+ .local/share/
+ .local/share/rhythmbox/***
# include mozilla and thunderbird folders AND files within them (3 "***")
+ .mozilla/***
+ .thunderbird/***
# exclude other hidden folders in /home/user directory
- .*
# exclude other folders and files within .local folder, except rhythmbox which is included above
- .local**
Start service and enable at boot:
sudo systemctl enable --now rsync-backup.service
====== Tested on ======
*
====== See also ======
* [[wiki:rsync_troubleshooting|rsync troubleshooting]]
====== References ======