This is quick guide, howto 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. If you installed and created testrepo with earlier guide then you can check real examples.
chown-R svnuser:svngroup /path/to/reponame
## If you use SELinux then remember also set security context ##
chcon -R-t httpd_sys_content_t /path/to/reponame
## Following enables commits over http ##
chcon -R-t httpd_sys_rw_content_t /path/to/reponame
Real example
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
2.4 Load Data to Repository from SVN (Subversion) Backup
the cron jobs need to escape the % character, like this
`@daily svnadmin dump /var/www/svn/testrepo | gzip -9 > /backups/testrepo-$(date +”\%Y-\%m-\%d-\%T”).dump.gz`
Step 1: I have created dump file as:
svnadmin dump D:\SVNRepo\Test > Test.dump
Step 2: Created Ne Repo as:
svnadmin create D:\SVNRepo\TestParent
Step 3: I want to load dump file in sub directory “TestNew” in D:\SVNRepo\TestParent
I’m tried as:
svnadmin load –parent-dir D:\SVNRepo\TestParent\testnew D:\SVNRepo\TestParent < test.dump
but not successful
How to do this? please provide example
Yes, backup and restore should work when you migrate a repository from server to another. One good thing is that, you can be exactly sure that new server works as you wish before you change anything on old server…
Thanks JR! This is very nice guide!
Thanks for the info. But you forgot to put .gz at the end of file in steps “2.1 Unzip Dump File” and “1.3 SVN Dump and Gzip Dump with One-liner”
Hi softboxkid,
Thanks, you are totally right! I fixed this guide! :)
the cron jobs need to escape the % character, like this
`@daily svnadmin dump /var/www/svn/testrepo | gzip -9 > /backups/testrepo-$(date +”\%Y-\%m-\%d-\%T”).dump.gz`
Hi felipe,
Excellent note! You are totally right! I fixed this.
Hi JR,
Could you add the “one line” command to load directly the dump.gz file in SVN repository?
thanks,
Yannick
Hi yannick,
Do you just mean something like following:
This is just example without setting SELinux security context.
Step 1: I have created dump file as:
svnadmin dump D:\SVNRepo\Test > Test.dump
Step 2: Created Ne Repo as:
svnadmin create D:\SVNRepo\TestParent
Step 3: I want to load dump file in sub directory “TestNew” in D:\SVNRepo\TestParent
I’m tried as:
svnadmin load –parent-dir D:\SVNRepo\TestParent\testnew D:\SVNRepo\TestParent < test.dump
but not successful
How to do this? please provide example
Thanks in advance….
Shrihari
Hi Shrihari,
This is actually Linux / Unix guide, but I quickly checked this and looks like Windows load syntax is following:
But before this, make sure that you backup your dump or test this on test environment, because I can’t verify is this working on Windows.
Great guide. Can you include a section on how to migrate a repository from one SVN server to another? Can backup and restore work?
Hi khalid,
Yes, backup and restore should work when you migrate a repository from server to another. One good thing is that, you can be exactly sure that new server works as you wish before you change anything on old server…