How to backup SVN repository? [duplicate]
Asked Answered
C

5

23

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?

Childhood answered 31/3, 2011 at 13:41 Comment(0)
F
24

I've used svnadmin with hotcopy.

svnadmin hotcopy repopath backupdestination

You can also use the svnadmin dump command.

Fecundate answered 31/3, 2011 at 13:46 Comment(2)
Can hotcopy be followed by a compression? Like svnadmin hotcopy -q repopath | bzip2 -9 > repo_backup.bz2Airburst
It should be able to, it's just piping the results into your zip command....Fecundate
B
24

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.

Breeze answered 31/3, 2011 at 13:46 Comment(0)
K
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.

Kailyard answered 5/8, 2013 at 16:12 Comment(0)
L
1

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.

Landseer answered 31/3, 2011 at 13:46 Comment(2)
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!Sandwich
I think dump/hotcopy savely handle potential concurrent access of other processes to the repositoryWildermuth
L
1

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

Legaspi answered 8/5, 2013 at 17:47 Comment(3)
How do you make sure no-one commits while you are doing that?Schrimsher
This only works if you don't have other commits coming in (e.g. only one developer). Not really a viable solution for most.Heidyheifer
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.Legaspi

© 2022 - 2024 — McMap. All rights reserved.