Using rsnapshot

Revision as of 22:27, 4 November 2019 by Ch (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

⇐ Backup

Using rsnapshot

rsnapshot is a utility that makes incremental backups and minimises disk space use by using Linux hardlinks

Install rsnapshot

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install rsnapshot

Configure rsnapshot
edit /etc/rsnapshot.conf
set root path to e.g.

snapshot_root /var/lib/rsnapshot/

end ensure we have the following command paths set

cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_du /usr/bin/du

set up the backup intervals to e.g.

retain alpha 6
retain beta 7
retain gamma 4
#retain delta 3

set the rsync args

rsync_short_args -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded

and set the rsync exclude file (see Using rsync),
If intending to backup locally exclude the path to localhost backups, e.g. /var/lib/rsnapshot
e.g.

exclude_file /PiBackup_exclude.txt

edit the backup point list, e.g.

backup / localhost/

Configure cron
add scripts to the /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly directories
of the form

#!/bin/sh
test -x /usr/bin/rsnapshot || exit 0
/usr/bin/rsnapshot alpha

substituting the appropriate backup interval name configured above, e.g. alpha, beta, gamma
Can keep a mirror on another server by using rsync
we keep hard links (which rsnapshot relies on) and use numeric-ids so that users aren't mapped from server1's user namespace to server2's
rsync -aHv --delete-delay --numeric-ids --exclude-from=/<excludefile>.txt / <dest> >> /<logfile>.log
this could be tagged onto the end of the /etc/cron.daily/rsnapshot cron job