rsync(1) has an excellent "--archive" option.
It provides my primary means of backup for when I occasionally want to see what my files looked like at some time in the past.
I happen to use a USB permanently plugged into the back of my monitor, but it could instead have been a separate device not physically close to my computer if I wanted a full backup for file-system recovery.
This is the script that I use for backups, running as root at 23:45 each day:
#!/bin/bash -e
# This is run as root at the end of the day
do what you want.
( echo ">>>>>>>>>>>>>>>>>>>>>>>" $(date)
today=$(date +%Y-%m-%d)
month=$(date +%Y-%m)
# USB backups
cd /media/ray/Backup-Ray
rsync --archive --one-file-system --delete --backup --backup-dir="../../$today/etc" "/etc/" "mostrecent/etc/"
rsync --archive --one-file-system --delete --backup --backup-dir="../../$today/home" --exclude=".config/google-chrome/" --exclude=".cache/" --exclude=".local/share/zeitgeist/" --exclude="Downloads/" "/home/" "mostrecent/home/"
rsync --archive $today/ $month/
echo "<<<<<<<<<<<<<<<<<<<<<<<" $(date)
) &>>/home/ray/Log/root.out
exit 0
All changed and deleted files are preserved. It's easy to use the standard unix tools to examine and recover files:
$ cd /media/ray/Backup-Ray
$ ls -l {,*}/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14002 Dec 3 21:04 2018-12-16/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14102 Dec 16 09:28 2018-12-17/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14202 Dec 17 20:47 2018-12-20/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14302 Dec 20 15:12 2018-12-25/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14402 Dec 25 21:21 2018-12-26/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14402 Dec 25 21:21 2018-12/home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14452 Dec 26 18:43 /home/ray/public/Log/wait.xhtml
-rw-r--r-- 1 ray ray 14452 Dec 26 18:43 mostrecent/home/ray/public/Log/wait.xhtml
Only the "mostrecent" directory is large.
The monthly accumulation directory (2018-12) contains the most recent changes throughout the month. It isn't necessary to do this step, but when I need to save space it allows me to delete all the daily updates for that month (A year from now I might care what things looked like at the end of December, but not so much how things changed within the month.)
Obviously you'd need to change the frequency, timestamps, etc., but the same mechanism should provide regular backups.
rsnapshot
seems like a good option if you are in a headless system. It even deals with cleaning up old snapshots it makes and that can be configured however you want, so you could keep snapshots for weeks or months ect whatever works best for you. They have a FAQ page which looks helpful. I will note that I have not usedrsnapshot
myself but from what I see of it it looks like a great tool and it will be my goto for this kind of thing. – Jeff Mar 19 '19 at 12:21