16

At this moment we are using Visual SVN and we are backing up the entire repositories directory for visual svn. This backs up the entire data for each repository inside our svn engine. I am curious if I will be able to restore those files in case of an emergency or a disaster? Any of you have experience with this restoration procedure? Thanks.

bahrep
  • 664
  • 1
  • 9
  • 27
Geo
  • 3,061
  • 11
  • 41
  • 52

7 Answers7

11

See: http://www.visualsvn.com/support/topic/00012/

That points to the following documentation:
http://www.visualsvn.com/support/svnbook/reposadmin/maint/#svn.reposadmin.maint.backup

It describes using the Subversion commands to take a backup. I hope this is what you are doing already because taking a straight directory backup can result in having a non-usable repository.

You should be able to use the backup from the Subversion and use svnadmin dump or svnadmin hotcopy command to restore the full repository. However, as with any backup strategy, you must test the restoration yourself to be sure it works for you.

bahrep
  • 664
  • 1
  • 9
  • 27
DCNYAM
  • 1,039
  • 7
  • 14
9

Starting with VisualSVN Server 3.6 version, the server includes a built-in scheduled repository backup and restore feature. Moreover, the 3.6 release adds scheduled verification of SVN repositories.

Setting up scheduled repository backup and verification for your Subversion repositories is only a matter of minutes. For step-by-step instructions, please see the article KB106: Getting Started with Backup and Restore.

If you look for a one-time backup, you could use Backup-SvnRepository PowerShell cmdlet. To recover the repository, use Restore-SvnRepository. These backup cmdlets are available beginning with version 3.6.

Download the latest version of VisualSVN Server from the main download page.

enter image description here


There are several methods to backup VisualSVN Server repositories. Check the short description below.

1. svnadmin hotcopy tool

svnadmin hotcopy allows you to make a safe copy of the repository, regardless of whether other processes are using the repository. You may write a custom script which will do the backup for your repositories on a regular basis.

You can consider the following article from SVN book to learn more about Subversion repositories backup: http://www.visualsvn.com/support/svnbook/reposadmin/maint/#svn.reposadmin.maint.backup

2. svnsync tool

This is the incremental backup method. Incremental backup method backups only the portion of the repository data that has changed since the previous backup. You can set up this tool to work as "master" and "slave" and duplicate any commits to its repositories automatically.

See the "svnsync" article for further details: http://www.visualsvn.com/support/svnbook/ref/svnsync/

3. Windows Server Backup. You can use Windows Server Backup to backup Subversion repositories. It allows you to shedule backups to a network share, dedicated backup volume, writeable media. For example, wbadmin command-line tool allows you to safely backup your repositories. This simple command performs one-time copy backup of C:\foo\bar to X:\ volume:

wbadmin start backup –backupTarget:x: -include:c\foo\bar -vsscopy

(To install Windows Server Backup, run ocsetup WindowsServerBackup in elevated command-prompt).

You can setup backup in different ways:

It's not required to stop server's service when you run the backup because FSFS repository backend is always in consistent state.

Here are general tips about recovering Windows Server backups:

  1. Recover backups to an empty directory to make sure that restored repository files won't mix with files of the broken one. After repository if recovered, you can delete broken repository and then replace it with the recovered one.

  2. Stop-start cycle server after recovering repository from a backup.

  3. If your clients get errors after repository recover, run svnadmin recover against it. The command finishes instantly and makes repository accessible again.


Except repositories, you should backup the following pieces of information:

  1. Authentication and authorization files that are stored in the repositories root ('C:\Repositories' by default). Depending on your settings, there should be the following files: 'authz', 'authz-windows' and 'htpasswd'.

  2. "%VISUALSVN_SERVER%\certs\" folder where information about your SSL-certificates is stored.

  3. "%VISUALSVN_SERVER%\conf\" folder where configuration files of your VisualSVN Server are stored.

  4. "HKEY_LOCAL_MACHINE\SOFTWARE\VisualSVN\VisualSVN Server" registry key where other part of server's configuration is stored.

bahrep
  • 664
  • 1
  • 9
  • 27
  • 1
    For your last option you'd have to stop the svn service, otherwise you risk backing up a repo where theres an active commit which will leave you backup corrupt. – Andy Feb 05 '14 at 02:09
5

I'm doing it by:

svnadmin dump "c:/Repositories/svnroot" > c:/backup/svnroot_%date%.dump

Also you can rar/zip it to save space. I was using the same method when I moved SVN from Linux to VisualSVN, so this backup works as it should.

Rob
  • 647
  • 1
  • 7
  • 27
Alex
  • 171
  • 1
  • 5
3

The easiest and best way to make backups of a SVN repo is to use svnsync. Its an incremental tool that replays any commits to a backup repository. Its easy to get going - see this blog post - and its fast as it only sends changes. You will have to set up a post-rev-prop-change hook to catch the 'edge case' of when someone updates a historical revprop, but otherwise you can run it hourly (as I do) to keep backups continually. you can even run it in the post-commit hook if you're really paranoid about data backup!

If your live repo dies, you can then just "svn relocate" to the backup repo until you have your live one running again (though, be careful if you write anything to the backup whilst the live is down unless you run svnsync to get those changes applied to the live repo, which is pretty obvious when you think about it).

So you have continuous backups, and downtime measured in seconds using it with minimal resource usage. Backups don't get much better than that!

gbjbaanb
  • 3,852
  • 1
  • 22
  • 27
3

Another option is hotcopy. It makes a back up of your entire repository. Takes up more disk space, but very easy to run and also very easy to restore repository using this.

swolff1978
  • 141
  • 3
2

VisualSVN is a Windows product so it'll be running on Windows. If the backup utility is able to use Volume Shadow Copy to make the backup, then that should produce an internally consistent backup. The built-in NTBACKUP or third party software such as Symantec Backup Exec, or the disk-based backup tools built into Windows Server 2008 are all capable of using Volume Shadow Copy.

Tim Long
  • 1,728
  • 1
  • 20
  • 41
  • This won't be transactionally sound. You need to get the server to do the backup one way or another, just as you do for any database. – David Heffernan Dec 05 '11 at 13:01
  • In the case of SQL Server, then VSS-based backups are in fact transactionally safe. In the case of VisualSVN server, one would hope that as a Windows based server, it would behave correctly when backed up by one of the standard windows backup solutions, as SQL Server does. I have no evidence to suggest whether it does or does not. – Tim Long Dec 05 '11 at 22:08
  • I doubt it. VisualSVN is simply svn packaged up. I've never seen any indication that it has backup that integrates with VSS. – David Heffernan Dec 05 '11 at 22:12
0

For those simply wanting to backup all repositories in a default install of Visual SVN on a Windows system

I use the following cmd script - It dumps all sub folders of the repository root to the backup path and 7-zips them.

@echo off
set svnAdminPath="C:\Program Files (x86)\VisualSVN Server\bin"
set sevenZipPath="C:\Program Files\7-Zip"
set repositoryRoot=d:\Repositories
set backupPath=c:\Source\Backup\SVN
set dateStamp=%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%

for /f %%f in ('dir /b /AD %%repositoryRoot%%') do ( 
call:dumpRepository %%f 
call:zipLastDump
)
goto:eof

:dumpRepository
cd /d %svnAdminPath%
set repoPath=%repositoryRoot%/%~1
set dumpFile=%~1_%dateStamp%
echo.-------------------
echo.Dumping %~1 to %dumpFile%.dump
echo.-------------------
svnadmin dump "%repoPath%" > "%backupPath%\%dumpFile%.dump"
exit /b

:zipLastDump
cd /d %sevenZipPath%
set zipFile="%backupPath%\%dumpFile%.7z"
echo.-------------------
echo.Zipping %dumpFile%.dump to %zipFile%
echo.-------------------
7z a "%zipFile%" "%backupPath%\%dumpFile%.dump" 
del "%backupPath%\%dumpFile%.dump" 
exit /b
JDizzle
  • 1
  • 1