Friday 8 September 2017

rsync (on FreeBSD, through cron) one-line incremental backup

Names have been changed to protect the innocent.
Creates a daily incremental backup archive of a remote site, hardlinked to save space. Logs changes.
Full paths are important due to cron environment!
Lines broken for web formatting...
/usr/local/bin/rsync -aizRH --stats -e "ssh -i /home/user/.ssh/id_rsa" --delete
 --link-dest=/home/user/backup/remotesite/`date -v-1d "+%Y-%m-%d"`
 root@www.remotesite.com:/etc :/var/www :/var/backups /home/user/backup/remotesite/`date +%Y-%m-%d`
 | /usr/bin/grep -E '^[^.]|^$' > /home/user/backup/remotesite/`date +%Y-%m-%d`.log
To clear old increments and save space:
/usr/bin/find /home/user/backup/remotesite -depth 1 -mtime +30d -exec rm -rf {} \;

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home