Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

How can I do daily backups for my VisualSVN Repos?

Its on a Windows Server 2003 machine with VisualSVN Server, I was thinking about just doing an xcopy of the folder C:\Repo but I'm not familiar enough with svn to know if that will cause issues.

Should I use dump or hotcopy or both?

share|improve this question

marked as duplicate by cole, squillman, Rex, voretaq7 Nov 1 '13 at 15:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
serverfault.com/a/407493/107134 –  bahrep Jul 13 '12 at 14:42

3 Answers 3

up vote 7 down vote accepted

It's a bunch of files, like any other bunch of files. Use whatever method you use to backup the rest of the system. As this is on a server I would have thought it would already be included in the regular backup scheme.

If you're using half-decent backup software, even Windows own NT Backup, it should be using the Volume Shadow Copy service, which will take care of open file issues, if any.

share|improve this answer
    
Did you mean "like any other bunch of files" ? –  Tim Long May 28 '10 at 22:03
    
@Tim Long - Rectified. I think I may have intended to write "not unlike". If you see this sort of thing in my questions or answers please feel free to edit them. –  John Gardeniers May 28 '10 at 23:04
    
Would have edited, but only having a 'mere' 694 rep is not enough to edit. –  Tim Long May 29 '10 at 20:42
    
It may be "a bunch of files" but those files are interdependent and cannot be copied instantaneously. Which could cause a "faulty backup". See my answer for the SVN documented solution. –  Byrån May 31 '10 at 4:07
1  
@Bryan, VSS should take care of the interdependence issue because it effectively takes a point in time snapshot prior to the backup. I certainly haven't experienced any issues doing my backups (and test restores) that way. –  John Gardeniers May 31 '10 at 4:31

Just copying the repo files is a bad idea:

...unless you temporarily disable all other access to your repository, simply doing a recursive directory copy runs the risk of generating a faulty backup.

You should use the The svnadmin hotcopy command.

Repository Maintenance > Repository Backup

You could script this and run it as a scheduled task.

share|improve this answer

I do both dump and hotcopy. Put them in a batch file and create a task with Task Scheduler to run it daily. Here is my sample batch file

!backing up credentials
copy H:\Repositories\authz G:\Repo-Backups\7-22-2013\backup
copy H:\Repositories\authz-windows G:\Repo-Backups\7-22-2013\backup
copy H:\Repositories\htpasswd G:\Repo-Backups\7-22-2013\backup

!full dump
svnadmin dump H:\Repositories\Proj1 > G:\Repo-Backups\7-22-2013\dump\Proj1
svnadmin dump H:\Repositories\Proj2 > G:\Repo-Backups\7-22-2013\dump\Proj2 

!hard copy
svnadmin hotcopy H:\Repositories\Proj1 G:\Repo-Backups\7-22-2013\backup\Proj1
svnadmin hotcopy H:\Repositories\Proj2 G:\Repo-Backups\7-22-2013\backup\Proj2 

If you have several repositories (projects) to backup and they change frequently it would be easier to have a little program create the above batch file for you. Here is what I've written for this purpose:

    public static void CreateBackupScript(string srcFolder, string desFolder, bool fullDump)
        { 
if (string.IsNullOrEmpty(srcFolder) || string.IsNullOrEmpty(desFolder))
            return;

        var dateString = DateTime.Now.ToShortDateString().Replace('/', '-');
        var destination = System.IO.Path.Combine(desFolder, dateString, "backup");

        if (!Directory.Exists(destination))
            Directory.CreateDirectory(destination);

        var source = srcFolder + "\\";
        var outputScript = "backup.cmd";
        using (StreamWriter sw = new StreamWriter(outputScript))
        {
            sw.WriteLine("!backing up credentials");
            sw.WriteLine("copy {0}authz {1}", source, destination);
            sw.WriteLine("copy {0}authz-windows {1}", source, destination);
            sw.WriteLine("copy {0}htpasswd {1}", source, destination);

            // dump
            if (fullDump == true)
            {
                sw.WriteLine("!full dump");

                var dumpFolder = System.IO.Path.Combine(desFolder, dateString, "dump");

                if (!Directory.Exists(dumpFolder))
                    Directory.CreateDirectory(dumpFolder);

                foreach (var dir in new DirectoryInfo(source).GetDirectories("*.*", SearchOption.TopDirectoryOnly))
                {
                    sw.WriteLine(@"svnadmin dump {0} > {1}\{2}", dir.FullName, dumpFolder, dir.Name);
                }
            }

            //hot copy
            sw.WriteLine("!hard copy");
            foreach (var dir in new DirectoryInfo(source).GetDirectories("*.*", SearchOption.TopDirectoryOnly))
            {
                sw.WriteLine(@"svnadmin hotcopy {0} {1}\{2}", dir.FullName, destination, dir.Name);
            }
        }
    }
share|improve this answer
    
+1 - this is very similar to how we back up our SVN repo's –  Mark Henderson Jul 23 '13 at 4:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.