Subversion is the popular version management system widely used for application developments. As a system administrator, you must know the importance of backups. So keep the backup of your all svn repositories on the local server as well as on remote systems. This article will help you to backup and restore the svn repository on the Linux system through the command line.

You can also set up your own SVN server on Debian based systems and Redhat based systems.

Backup SVN Repository

Subversion provides svnadmin utility for managing svn repositories. We can also take a backup of svn repositories using the svnadmin command.

svnadmin dump /var/svn/myrepo > /backup/svn/myrepo.dump

* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.

We can also compress backup with gzip and save disk space. Use the following command to backup the svn repository and compress it using gzip command.

svnadmin dump /var/svn/myrepo | gzip -9 > /backup/svn/myrepo.dump.gz

Restore SVN Repository

Now if you are required to restore your svn repository from backup. Use the following example to restore the repository from a backup file. For this example, we are creating a new repository to restore the dump.

First create a new repository using create option.

svnadmin create /var/svn/mynewrepo

Now restore backup to newly created repository using following command.

svnadmin load /var/svn/mynewrepo