Automated Remote Backups with rsync
One of the oldest and simplest ways to back up UNIX-like systems is with rsync. Automated remote backups are a simple matter of setting up rsync as a daemon on the system you want to back up and running an appropriate rsync command as a cron job on the backup target.
Let's create /etc/rsyncd.conf on the machine to be backed up:
[etc] path=/etc read only=TRUE hosts allow=192.168.0.0/24 hosts deny=* uid = 0 exclude = ssh/
Any number of modules can be defined with the [module_name] convention so different settings can be applied to different locations on the file system. Module names are used in the rsync:// protocol format insted of full path names. This block says, in English: Serve the contents of /etc/ except /etc/ssh/ to any host on the 192.168.0.0 subnet at the location rsync://localhost/etc as though root was reading the files but don't allow any modifications to the local file system.
Read the rsyncd.conf man page for more configuration options. Your rsync package probably comes with a compatible init script, be sure to enable it for your default runlevel.
On the backup server we'll drop this little bash script into /etc/cron.hourly:
#!/bin/bash rsync -a -u --delete rsync://192.168.0.10/etc /mnt/backups/serverxyz/etc
Now every hour the backup target will connect to the rsync daemon and download any files which have been changed or do not already exist in the backup tree, also deleting files which no longer exist on that server to preserve space.
Comments
There are no comments for this item.