User Tools

Site Tools


wiki:systemd_rsync_service

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

References

wiki/systemd_rsync_service.txt · Last modified: 2023/06/27 10:19 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki