This document describes howto use rsync and the required configuration to have duplication of a cvs tree in a secondary cvs server for backup. The secondary cvs server will use rsync over ssh (public key based auth) to synchronize with the primary cvs server.
master.com$ su - rsync master.com$ ssh-keygen -t rsa
The keys will be placed in /home/rsync/.ssh.
master.com$ cat /home/rsync/.ssh/id_rsa.pub > /home/rsync/.ssh/authorized_keys master.com$ ssh-copy-id -i /home/rsync/.ssh/id_rsa.pub rsync@slave.com
rsync --daemon --config=/usr/local/etc/rsync.conf
See man rsync.conf for details on the configuration file.
The rsync.conf file controls authentication, access and logging. We will rely on ssh for authentication and security.
Set up the file /usr/local/etc/rsync.conf on master.com (primary cvs server) as fllows :
pid file = /var/run/rsync.pid uid = cvs gid = cvs [cvs] path = /somepath/cvsroot comment = cvs repository
The goal is to implement the following policy using the adequate rsync options.
Commands to issue on the machine hosting the secondary repository (slave.com)
/usr/local/bin/rsync -urtpgv --delete-after -e "ssh -i /home/cvs/.ssh/id_rsa_cvs" cvs@master.com::cvs /somepath/cvsroot
Here is the command to update the primary cvs repository on master.com
/usr/local/bin/rsync -urtpgv --delete-after -e "ssh -i /home/cvs/.ssh/id_rsa_cvs" /somepath/cvsroot cvs@master.com::cvs
Add crontab entries on the machine hosting the secondary repository slave.com
01 05 * * * /usr/local/bin/rsync -urtpgv --delete-after -e "ssh -i /home/cvs/.ssh/id_rsa" cvs@master.com::cvs /somepath/cvsroot | mail -s "[cron] [rsync-in] [slave.com]" your-email 01 07 * * * /usr/local/bin/rsync -urtpgv --delete-after -e "ssh -i /home/cvs/.ssh/id_rsa" /somepath/cvsroot cvs@master.com::cvs | mail -s "[cron] [rsync-out] [slave.com]" your-email
| Labels: howto, coding, unix |
|