- Make the hostname for your raspberry pi available on your client, e.g. by editing
/etc/hosts
:<ip-address> raspberrypi
- Enable the rsyncd service and run it on a nice level of 10 or something.
On my machine it worked by installing a systemd service by creating
/lib/systemd/system/rsync.service
:Enabling and starting it via[Unit] Description=fast remote file copy program daemon ConditionPathExists=/etc/rsyncd.conf [Service] ExecStart=/usr/bin/nice /usr/bin/rsync --daemon --no-detach [Install] WantedBy=multi-user.target
sudo systemctl daemon-reload sudo systemctl enable rsync sudo service rsync start
- Export the folder you want to backup as
backupsrc
viarsync
by adding the following to your/etc/rsyncd.conf
Maybe you need to restart the rsync daemon afterwards.#global (globale einstellung) log file = /var/log/rsync.log timeout = 300 [backupsrc] path = <backup-path> comment = <some comment> max connections = 1 hosts allow = raspberrypi hosts deny = * use chroot = yes # Don't know what this does list = true # Maybe no? uid = root # No clue gid = root # No clue read only = true # Sound's good
- To install the scripts, clone the repository onto the raspberry and make it accessible to root (i.e. clone it into
/root
). - Add an entry to your
/etc/fstab
to mount the backup destination to/root/snapshots
:You can determine the UUID usingUUID=<uuid-of-your-backup-drive> /root/snapshots ext4 ro,suid,dev,noexec,nouser,async,noauto 0 0
sudo lsblk -o +uuid
. - Make the hostname for the machine you want to backup available on your raspberry pi, e.g. by editing your
/etc/hosts
:<ip-address> backup-client
- Create cronjobs which do the backups using
crontab -e
as root:# m h dom mon dow command # Run an hourly backup every hour. 0 * * * * /root/backupsrv/take_snapshot.sh --host backup-client --turnus hourly --count 4 # Use the latest hourly snapshot as a daily snapshot every day at 07:45. 45 7 * * * /root/backupsrv/rotate_snapshot.sh --host backup-client --turnus daily --count 7 --turnus-fast hourly --count-fast 4 # Use the latest daily snapshot as weekly snapshot every monday morning at 03:00 0 3 * * 1 /root/backupsrv/rotate_snapshot.sh --host backup-client --turnus weekly --count 4 --turnus-fast daily --count-fast 7
Now your raspberry should be setup make rotating backups if your machine is available when the cronjobs execute.
Export /root/snapshots
as read only NFS mount to your backup client and configure your backup client
to mount it someplace, e.g. /snapshots
.
TODO: Specify
The scripts are based on the following articles: