Backup and Restore SVN repository on CentOS/RHEL

This is entirely very simple and important task. SVN backup and restore is valuable when you need to move your repos to new server or you have to recover your data. I expect here that you have Subversion (SVN) installed and you have existing repositories.


Backup (Dump) SVN Repository

We’re presently going to create a .dump record which contains the whole history of modifications for our repository. To make a complete backup run the following command:

# svnadmin dump /var/www/svn/repos/test > /backup/test.dump
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4.

Compressed Backup (Dump) SVN Repository

As a rule the dumps are large files, it is fitting to compress the dump. Following command will compress the backup file and reduce the size of the file.

# gzip -9  /backup/test.dump

Backup (Dump) and Compress SVN Repository

If you take backup and compress it then it will take time. So you can preform both task in single command using following command.

# svnadmin dump /var/www/svn/repos/test | gzip -9 > /backup/test.dump.gz

Restore (Load) SVN Repository

Now that we have our .dump file, we can use it to restore our repository. To restore your repository run the following command:

First create a new repository and set permission, where you have to restore the backup.

# svnadmin create /var/www/svn/repos/myrepo
# chown -R apache.apache myrepo

After creating the new repository now we restore dump to newly created repository.

# svnadmin load /var/www/svn/repos/myrepo < /backup/test.dump
<<< Started new transaction, based on original revision 1
     * adding path : mobile ... done.
     * adding path : mobile/code ... done.
     * adding path : mobile/document ... done.
     * adding path : webproject ... done.
     * adding path : webproject/code ... done.
     * adding path : webproject/document ... done.

------- Committed revision 1 >>>

<<< Started new transaction, based on original revision 2
     * adding path : webproject/code/New Text Document.txt ... done.

------- Committed revision 2 >>>

Unzip and Restore (Load) SVN Repository

If backup file is in compress mode then you can restore it without doing unzip. Use following command to perform this:

gunzip -c /opt/test.dump.gz | svnadmin load myrepo

Reference Articles:

How to Configure SVN Server on CentOS/RHEL
How to Configure SVN Server with LDAP Authentication on CentOS/RHEL

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.