Backup and restore or migrate subversion/svn repositories

From Andreida
Revision as of 11:58, 16 February 2016 by Andreas (talk | contribs) (Created page with "The created text file is NOT plain text! from http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.migrate == create the svn backup == svnadmin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The created text file is NOT plain text!

from http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.migrate

create the svn backup

svnadmin dump <directory> > dumpfile

Example

ls -l /repositories/
drwxr-x--- 7 www-data www-data 4096 Jan 26  2013 test

Create the dump file

svnadmin dump /repositories/test/ > svn-test.dump
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.
* Dumped revision 4. 
ls -l
-rw-r--r-- 1 root root 1800 Jul 17 10:59 svn-test.dump

Compress the file

tar -czf `date +%F`-svn-test.dump.tar.gz svn-test.dump
ls -l
total 8
-rw-r--r-- 1 root root  631 Jul 17 11:03 2015-07-17-svn-test.dump.tar.gz
-rw-r--r-- 1 root root 1800 Jul 17 10:59 svn-test.dump

restore the svn backup into (another) repository

svnadmin load <directory> < dumpfile

Example

ls -l /repositories/
drwxr-x--- 7 www-data www-data 4096 Jan 26  2013 test

Create the new repository

svnadmin create /repositories/test-2
ls -l /repositories/
drwxr-x--- 7 www-data www-data 4096 Jan 26  2013 test
drwxr-xr-x 6 root     root     4096 Jul 17 11:16 test-2

Correct owner

chown www-data:www-data -R /repositories/test-2/
drwxr-x--- 7 www-data www-data 4096 Jan 26  2013 test
drwxr-xr-x 6 www-data www-data 4096 Jul 17 11:16 test-2

Correct rights (if you use different user/group, think about the needs)

chmod -R 770 /repositories/test-2/
ls -l /repositories/
drwxr-x--- 7 www-data www-data 4096 Jan 26  2013 test
drwxrwx--- 6 www-data www-data 4096 Jul 17 11:16 test-2

"Restore" the date into the new repository

svnadmin load /repositories/test-2/ < svn-test.dump

give rights to users

Do not forget to allow access to the new repository, if you have no idea, take a look here: http://wiki.andreas-duffner.de/index.php/Svn_via_https