Backing up and restoring SVN repositories
2 ways to back up subversion repositories; first is to dump the repo and reload it in another repo, and the second is to use hotcopy. The hotcopy technique has a more stringent requirement than using the dump technique–hotcopy requires that the version of SVN on the 2 servers (source and target) are the same, the platform is the same etc.
This short note uses the dump technique for SVN.
Backup the source repository
We’ll need to create a backup of the source repository (your current repository) using svnadmin dump. Ideally, you will include this in a backup script that runs regularly–either using task manager or cron jobs. Here’s the script
$ svnadmin dump /path/to/your/svn-repository > yourbackup.dump
The dump file could be large since it will contain all the revisions (deltas) that you have made in that repository–it will even include files that you have deleted in the repo.
Moving the dump to new repository
Find a way to transfer the dump file into the newly prepared SVN server–this could be done using simple FTP, secure FTP or simply copying it using a USB disk; it’s a simple file transfer operation.
You need to create a new repository on the new server first, then load up the dump file.
$ svnadmin create /path/to/your-new-repository
$ svnadmin load /path/to/your-new-repository < /path/to/yourbackup.dump
[Optional step] If you have exposed your SVN repository using http (behind Apache), don’t forget to change the owner (chown) of the new SVN repository.
$ sudo chown -R www-data:www-data /path/to/your-new-repository //if you are on Debian or Ubuntu
$ sudo chown -R apache.apache /path/to/your-new-repository //if you are using CentOS or Fedora
Now, the move is complete.
Leave a comment