How to backup SVN repository?

60,979

Solution 1

I've used svnadmin with hotcopy.

svnadmin hotcopy repopath backupdestination

You can also use the svnadmin dump command.

Solution 2

You could use svnadmin dump. For example, to create a compressed backup file in Linux run:

svnadmin dump -q /path/to/repo | bzip2 -9 > repo_backup.bz2

To restore a backup use svnadmin load:

svnadmin create /path/to/newrepo
bzip2 -cd repo_backup.bz2 | svnadmin load /path/to/newrepo

See also Repository data migration using svnadmin in the SVN Book.

Solution 3

I have made use of the post commit hook to make an incremental backup:

REM Backup of Revision

MD "C:\SVN Backup\Incremental\%TYPE%"

set TYPE=2020

set ADMIN="C:\Program Files (x86)\WANdisco\uberSVN\bin\svnadmin.exe"

set ZIP="C:\Program Files\7-Zip\7z.exe"

%ADMIN% dump %REPOS% -r %REV% --incremental | %ZIP% a -si "C:\SVN Backup\Incremental\%TYPE%\%2.7z" -mmt -mx9

In addition to the incremental dump, I have a weekly batch file that runs that does a full dump. A little overkill, but all the dump files are zipped with the 7 Zip command line utility. Thereafter it is sync'd to our usual backup medium.

EDIT - Updated the code with the latest where I am zipping the dump files with the 7 Zip command line utility to save some space.

Solution 4

I just zip the repository once a week and copy the zip file to a different storage location.

Solution 5

Just copy and compress the whole repository folder, that'll allow you to easily get back to different points in time. Of course, you have to make sure not to do it while the repository is being used or god knows what might happen :)

On Windows you could use VSS to make sure you take a consistent backup or take the backup at night when it isn't being used.

Alternatively, check this similar question or that blog post.

Share:
60,979
sharptooth
Author by

sharptooth

Updated on June 21, 2020

Comments

  • sharptooth
    sharptooth about 4 years

    I often hear that having an SVN repository doesn't cancel need for backups.

    How is such backup done? I mean the repository will inflate over time, won't it? So do I back it up as a whole every time or what do I do?

    What's the easiest way to do such backups?

  • Thunder
    Thunder almost 12 years
    This brings up the another question =>what is the difference between copying the repository manually and using svnadmin dump -q /path/to/repo | bzip2 -9 > filename.bz2 ? Which one is the better option I think both works I tested it!
  • Martin Thompson
    Martin Thompson over 10 years
    How do you make sure no-one commits while you are doing that?
  • codewario
    codewario over 10 years
    This only works if you don't have other commits coming in (e.g. only one developer). Not really a viable solution for most.
  • Rafael Anschau
    Rafael Anschau about 10 years
    Yes it´s a situation with only one developer. I imagine that in a situation with more developers, one could configure the SVN tool to temporarily reject commits with a message like "Server in backup process, please try again in 10 minutes" but I am not sure if it currently supports that.
  • molecular
    molecular over 7 years
    I think dump/hotcopy savely handle potential concurrent access of other processes to the repository
  • Sandburg
    Sandburg over 5 years
    Can hotcopy be followed by a compression? Like svnadmin hotcopy -q repopath | bzip2 -9 > repo_backup.bz2
  • Kevin LaBranche
    Kevin LaBranche over 5 years
    It should be able to, it's just piping the results into your zip command....