alternative svn backup method

November 20, 2010

alternative svn backup method. Sometimes svnsync, hotcopy, etc just won’t work for you. Here’s the solution!

1. Create a user with same name and password on each of your servers, example:
host1_live_svn_server – backup_usr
host2_backup_server – backup_usr
2. Setup SSH with no password for each user that will be involved in syning your svn
3. edit /etc/group and add backup_usr to whatever group owns /usr/local/svn (assuming that is your svn install dir)
4. Install rsync on each server
5. test this command (you can ctrl + c if successful):
host1_live_svn_server# ssh backup_usr@host2_backup_server rsync -avK backup_usr@host1_live_svn_server:/usr/local/svn/* /usr/local/svn
(if this errors out try putting a \ in front of the *)

Create a new file called backupsvn.sh:

#!/usr/local/bin/bash
/usr/local/sbin/apachectl -k stop
host1_live_svn_server# ssh backup_usr@host2_backup_server rsync -avK backup_usr@host1_live_svn_server:/usr/local/svn/* /usr/local/svn
/usr/local/sbin/apachectl -k start

Place the file in cron so you can backup svn nightly!

If you receive error message:
ssh: No match.

You need to take the following steps:
ssh in to each server (server1 to server2 and vise versa) and accept:
1. the RSA key
2. chsh -s /usr/local/bin/bash
3. Make sure rsync is installed on both servers (‘which rsync’)
4. if this keeps happening you probably change the fully qualified domain name or ip of where you were connecting, please set up ssh with no password again http://brakertech.com/add-public-ssh-key-to-remote-server-in-a-single-command/

If you get any permissions errors with rsync be sure to add your user to /etc/group under whatever group owns the svn files