Search code examples
svnbackup

How do I back up a remote SVN repository


I am currently moving my SVN server from my home server to my remote server so I can access it more easily from other locations. My remote server is not backed up so I want to regularly back it up to my home server.

Remote server is Windows 2003 server. Home server is Windows Home Server.

What is the best way to do this? can I get my home server to get a dump of the remote server every night? Bandwidth isn't a huge consideration but if I could just copy any new checkins to an SVN server on my home server that would be fine.

Any suggestions welcome.


Solution

  • Just use the svnsync command.

    First, create a fresh repository on your home machine.

    svnadmin create c:\backuprepo
    

    Or on Unix:

    svnadmin create ./backuprepo
    

    Next, create a file named pre-revprop-change.bat:

    echo exit 0 > c:\backuprepo\hooks\pre-revprop-change.bat
    

    Or on Unix:

    echo -ne '#!/bin/sh\nexit 0' > ./backuprepo/hooks/pre-revprop-change
    chmod ugo+x ./backuprepo/hooks/pre-revprop-change 
    

    then, initialize the sync:

    svnsync init file:///c:/backuprepo https://url/of/your/repository
    

    Or on Unix:

    svnsync init file:///Volumes/volumelabel/backuprepo https://url/of/your/repository
    

    After that, you can simply run

    svnsync sync file:///c:/backuprepo
    

    once a day or so, and you'll get only those changes which are not yet in your backup repository. The first time it will take a while, but after you've synchronized your backup repository with the real one, it will only take a few seconds to sync it because only those revisions that are new need to be synched.