Svn – using rsync to backup subversion repositories

rsyncsvn

CentOS 5.3
subversion 1.4.2

I am looking for a strategy to backup our subversion repositories. We have about 30 repositories in a directory like this:

repos/
     /DEVS
          /reps1
          /reps2
     /WEB
          /reps3
          /reps4
          /reps5
     TOOLS/
          LIBS/
              /reps6
              /reps7
          LOGS/
              /reps8

Our requirement is to do daily backups running at 12am.

However, I am not sure about the subversion repositories in order to set things up for rsync.

Do I need to do a hotcopy or svn dump, syn sync, etc? Or do I just copy the repositories as they are?

I have never used rsync before so we will be backing up our repositories to a remote server. Do I need rsync daemon running on both machines?

Can rsync recursively backup all the repositories under the directory repos?

Many thanks for any advice,

Best Answer

You need to make sure that the repository is not changed at all (i.e. new check-ins) while the backup is taking place. This can be arranged a number of ways but probably the easiest is to use hotcopy to make a new copy of the repository (the process respects subversions versioning/locking system so you get a consistent point-in-time copy of the repository even if people are actively using it) then backing that copy up to the remote site using rsync.

rsync supports syncing full directory structures, and if the remote end is contactable via SSH (or similar) you don't need to be running the rsync in daemon mode (it just needs to be installed so it can be called via ssh).

The rsync command you need is probably of the form:

rsync -a /path/to/hotcopy/copy user@remote.host:/path/to/backup/location

This connects to remote.host via SSH as user, starts an rsync process, and arranges the transfer with it then closes it before closing the SSH session. The -a option (short for --archive) includes a lot of options including the one that causes rsync to operate recursively over a whole directory structure. You might want to add the --compress option too as no doubt your repository's contents will compress well saving you some bandwidth. See the rsync man page for more details.

Related Topic