Configure SVN (Subversion) Backup and Restore

SVN (Subversion) Backup and Restore


This section will show how to Backup (dump) and Restore (load) SVN (Subversion) repository on Linux. This is actually very simple and important task. SVN backup and restore is useful when you want to move your repos to new server or you need to recover your data. I assume here that you have Subversion (SVN) installed and you have existing repositories. please see the guide if you are not setup SVN repositories Click  here. If you installed and created testrepo with earlier guide then you can check with examples.



Backup (dump) SVN (Subversion) repository
General syntax 
# svnadmin dump /path/to/reponame > /path/to/reponamedump
Ex:
# svnadmin dump /var/www/svn/testrepo > /backups/testrepo.dump  

Compress the Dump 
gzip -9 /path/to/reponame.dump

Ex:

gzip -9 /backups/testrepo.dump                          



SVN 
Dump and Gzip Dump with One line
# svnadmin dump /path/to/reponame > /path/to/reponamedump

Ex: 
# svnadmin dump /var/www/svn/testrepo > /backups/testrepo.dump  
Restore (load) SVN (Subversion) repository
Unzip Dump File
gunzip /path/to/reponame.dump.gz

Ex:
gunzip /backups/testrepo.dump.gz


Create Empty SVN (Subversion) Repository

Before restore any repo we have to create the repo 
name in our local SVN

# svnadmin create /path/to/reponame

Ex:
# svnadmin create /var/www/svn/testrepo



Setup SVN (Subversion) Repository Permissions
# chown -R apache:apache /var/www/svn/testrepo

## Set security context ## 
# chcon -R -t httpd_sys_content_t /var/www/svn/testrepo

## Following enables commits over http ##
# chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo
  
Restore Data to Repository from SVN (Subversion) Backup
# svnadmin load /var/www/svn/testrepo < /backups/testrepo.dump
Automatic SVN (Subversion) Repository Backups

# crontab -e

Add SVN Dump Command to Crontab
@weekly svnadmin dump /var/www/svn/testrepo > /backups/testrepo.dump

More Advanced SVN Dump Example with Time and Date and Gzip
@daily svnadmin dump /var/www/svn/testrepo | gzip -9 > /backups/testrepo-$(date +"\%Y-\%m-\%d-\%T").dump.gz 

Related links:

How to Backup and Restore SVN Repos
 



Keywords: Subversion, SVN, SVN Server, Adding Users on SVN Server, Backup SVN, Restore SVN.

Comments

Popular posts from this blog

Observium: Configuring Microsoft Windows 2008 Server SNMP Agent

AWS: Introduction to AWS (Amazon Web Services)

System/Server Health Status using PowerShell