8

Right now I am using Windows XP. If i just copy the whole repository folder in visual SVN, once the server is down, how can i restore it via the backuped repository folder? another better solution to backup and restore in visual svn ?

by the way, any method for backup and restore in visual source control?

MemoryLeak
  • 7,322
  • 23
  • 90
  • 133

4 Answers4

29
svnadmin dump /path/to/repository | bzip2 -9c > svn-backup.bz2

The compression step is optional, of course.

The primary advantage of this over the "copy the tree" method recommended in another answer is that the Subversion "dump" format is a better archival format than most of the database formats used by Subversion under the hood in its repository. (It's a speed vs. simplicity tradeoff.) You can read a dump file in a text editor, parse it easily, and — most important — import it into a different Subversion repository using a different database back-end.

Restore the above file with:

bzip2 -dc svn-backup.bz2 | svnadmin load /path/to/repository
Warren Young
  • 40,875
  • 8
  • 85
  • 101
6

This is what I use:

#!/bin/bash

mkdir /tmp/backup_svn

for dir in /var/www/svn/*/
    do
        dir=${dir%*/}
        svnadmin dump "${dir}" > "/tmp/backup_svn/${dir##*/}.dmp"
    echo "--- Dump ${dir##*/} done!"
done

To restore the dump you need to create de repo folder before:

svnadmin create /var/www/svn/test

And them:

svnadmin load /var/www/svn/test/ < /tmp/backup_svn/test.dmp

This method will restore all revisions/tags/branches in your repository.

Diego Mariano
  • 191
  • 2
  • 6
2

You should use svnadmin hotcopy to create a backup of your repository.

bahrep
  • 29,961
  • 12
  • 103
  • 150
wierob
  • 4,299
  • 1
  • 26
  • 27
  • 1
    Is that really true? Everything I've read, incl. mailing list notes from K. Fogel and B. Collins-Sussman, says that "svn dump" is just fine for backing up the *data* stored in the repository. If you want to back up lock information or some such, you might want hotcopy, but almost no one does, right? – Michael H. Feb 28 '11 at 19:09
-3

You can just copy the entire directory in and out. Files is files, there's nothing magic about them.

If you want to do something more complicated, like edit the repository contents in some way before restoring, then you need dump and load.

Jay
  • 26,876
  • 10
  • 61
  • 112
  • 6
    If you use the copy-file method while the repository is "hot" you could end up with corrupt data. Some data before commits and some data after commits. – Peter Ritchie Nov 10 '11 at 14:58
  • 2
    I would not recommend this. SVN repository should be handled using svnadmin command only. – Suyash Jain Dec 04 '17 at 04:36
  • This should not be the accepted answer for the above mentioned reasons. – teroi Jan 25 '18 at 09:46
  • Had someone implemented this solution at work, if you don't have the same subversion version on the new server, subversion may have problem reading the files and the restore won't work. Don't use this. – Béatrice Cassistat Aug 13 '20 at 19:26