Subversion has been used as my project version control system for years. Backup and restore subversion data will be a critical issue. Here are three ways to create a full mirror of a Subvrsion repository:
- File Copy: treat the repository like any other filesystem and recursively copy it to the mirror location.
- Dump/Load: Use svnadmin dump and svnadmin load.
- Hotcopy: Use svnadmin hotcopy.
3 Ways to Backup Subversion Reviews
All these ways have their own advantage and disadvantage. In the following table, I will show the different between these 3 ways.
|Method||Server Downtime||Replicates Configuration||Speed|
Backup subversion repository by copying
The only limitation of this backup way is the subversion system should be taken down when we are copying the repository to target. The command line of copy a subversion repository is
>cp -R path_of_repository path_of_destination
Backup subversion by svnadmin dump and load
Svnadmin dump is designed to create a portable repository dump. The resulting dumpfile can be loaded into a new Subversion repository – even if the new repository is using a different database backend, or even a different revision of Subverson. And you don’t need to take down the Subversion server when running the Svnadmin dump. This is the most common way to backup a Subversion repository. The command line looks like:
>svnadmin dump PATH_OF_REPOS > backup.dump >svnadmin load PATH_OF_MIRROR < backup.dump //this is comment >
Backup subversion by svnadmin hotcopy
The svnadmin hotcopy doesn’t require any server downtime, completes in minutes, and replicates server configuration and hoot scripts. The command line is:
svnadmin hotcopy path_of_repository path_of_destination
Restore svn repository from hotcopy
Hotcopy is just like a copy. So the final backup folder is mirror repository which you can use directly. If you want to restore repository from hotcopy backup, you can easily copy the backup files back to your repository location.
SVN Trouble Shoot
When I am running
svnadmin dump command, I get following error message:
svnadmin: Expected FS format between ‘1’ and ‘4’; found format ‘6’
It is because the svn and svnadmin version is too old. My current version is 1.6. I am going to the visualsvn.com and get the latest visual svn server. After I update the svn to 1.8, the problem is solved. You can using following command to get your svn and svnadmin version number.
>svn --version >svnadmin --version
Another problem about the svnadmin dump is it doesn’t work with url. If you are running following command, you will get error:
svnadmin: ‘http://projectname.googlecode.com/svn’ is an URL when it should be a path
One solution for it is create a local svn repository and synchronize with the remote server.