To backup your VisualSVN repositories, you will need the following
- Windows powershell installed and configured to allow scripts to run. If you’re unsure of how to enable powershell scripts to run locally, see this superuser thread
- A place to backup files. I have mine synced to a local folder, which is then synced to OneDrive
Step one. Create a text file and change the extension to .ps1
The file would be something like VisualSVNscript.ps1
Step two. Add the following lines to the file
#Name of project1 Remove-Item -Recurse -Force <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> svnadmin.exe hotcopy <PUT YOUR PROJECTS SOURCE DIRECTORY HERE> <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> #Name of project2 Remove-Item -Recurse -Force <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> svnadmin.exe hotcopy <PUT YOUR PROJECTS SOURCE DIRECTORY HERE> <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> #Name of project3 Remove-Item -Recurse -Force <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> svnadmin.exe hotcopy <PUT YOUR PROJECTS SOURCE DIRECTORY HERE> <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> #Name of project4 Remove-Item -Recurse -Force <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE> svnadmin.exe hotcopy <PUT YOUR PROJECTS SOURCE DIRECTORY HERE> <PUT YOUR PROJECTS DESTINATION DIRECTORY HERE>
You will need to do this PER project! Hotcopy can only copy to an empty directory, so we delete the contents of the directory first then copy the newest code to the directory. Save the file and exit
Step three. Use Windows Task Scheduler to run the script automatically for you.
- Press Start and start typing “Task Scheduler”. Click on it.
- Click create basic task, name the task “VisualSVN backup” or anything you like and select desired frequency
- For a command enter in “powershell -file <pathtoscript>” and click Finish
Hello Evan,
Thank you for this post!
I would remove `Remove-Item -Recurse -Force` commands from the script. There is a chance that a user unintentionally confuses and and the script will remove the repositories instead of making backup.
BTW, VisualSVN Server 3.6 will introduce a built-in backup solution[1] and it is going to be released in short time. I guess that you might want to try Release Candidate build of the upcoming version. You can download it at https://www.visualsvn.com/server/download/pre-release/
[1]: https://twitter.com/visualsvn/status/837346777808285697
Hey bahrep,
The reason I force removal is because I was getting an error message saying that the directories were not empty. But I completely agree with the potential for a user wiping their own repository, which is why in my example I caps-locked everything.
I’ll have a look at the release candidate of VisualSVN, that feature looks pretty slick/easy