Moving an SVN repo from VisualSVN to a Synology NAS SVN server by Paul Sammut

New Synology DS416j server tucks away nicely. 

New Synology DS416j server tucks away nicely. 

I recently got a purty DS417j Synology NAS device in hopes of having it take care of my data and SVN server woes. The way I was operating my SVN server before was on an 5 year old laptop connected to an external hard drive which I would access whenever I was out and about through Hamachi. This worked, but I wasn't backing stuff up and sometimes my old laptop would shutdown leaving me with no SVN server. I wanted something a little more stable and... proper if you will.

So, right off the bat, the Synology is really easy set up while still being a linux based server with lots of capabilities like one-click free external domain name service all while automagically setting up your router to handle all the port forwarding necessary. 

Old VisualSVN server. Time for a new one. 

Old VisualSVN server. Time for a new one. 

Here's the step by step process that explains how to setup an SVN server on your Synology NAS and import a repository that was being hosted by VisualSVN on a windows machine. This assumes the following:

  • You are a linux idiot but you know how to use putty to SSH into a linux machine  
  • You want to setup an SVN server on a Synology NAS (this tutorial was with DSM 6.0.2)
  • You currently have a VisualSVN server running on a windows machine and want to migrate
  • You have a BIG SVN REPO. Mine was 30 gigs. 

Step by Step Guide

Step 1: Install SVN on your NAS

Install SVN on your NAS. Click on package center and search for SVN and hit that install button. You can leave in the default settings during install. This will create an SVN folder in your file station. 

Once you've installed the SVN package it should have automatically forwarded the SVN port on your router. You can verify this by going to Control Panel > External Access > Router Configuration tab and making sure you see the SVN port. 

Step 2: Copy repository to the NAS

Installing the SVN program creates an svn folder on your NAS root directory. On the diskstation dashboard go into Control Panel > User > click your username > Permissions and give yourself read/write access of this folder. 

Once you haven permission, copy the repository from your VisualSVN server location to the NAS. I highly suggest you do this using FTP. Copy the repository main folder and all its contents into the svn folder. When you're done you'll have something that looks like this, with my repo called RoboDolf. 

Step 3: Verify the migrated repository

If you haven't enabled SSH, enable it by going into Control Panel, Terminal & SNMP and click on Enable SSH service.

Open a terminal window and SSH into the Synology NAS using your username and password. Once in, run:

svnadmin verify /location/of/your/svn/repo

This will verify the repo and make sure that it's good. On my 30 gig repo, it only took a couple of minutes to verify. Once you've verified, you're almost there!

Step 5:  Add users to the repo

Open the SVN program on the Synology dashboard by going to main menu (weird icon on the top left) and then click on the SVN server icon. You should see your repo listed and if you click edit it'll give you the address for it (this is the local address and not external and won't work outside your network, see below how to get it working with the outside world). 

Then click on User in the Edit Repository window and add an SVN account. This will be the username and pass you'll use to login to the svn server. Also, select anonymous permission to NONE. 

Step 6: Checkout/Relocate the repo!

Now go to your development machine and use the address to check out the repository. Done and done! (kinda)

If you have a working copy on a windows machine you want to relocate and link to your band new Synology server go to the repo folder, then right click it > TortoiseSVN > relocate. Then put in the address of your brand spankin new server. 

One last step is to give write access to the repo by editing the svnserve.conf file found in /svn/YourRepoName/conf directory on your new NAS SVN server. To do this you have to ssh into your server and use VI (text editor over ssh)

vi /your/svn/dir/YourRepo/conf/svnserve.conf

and uncomment (delete the #) from the following lines. 

auth-access = write
password-db = passwd

Save the file by pressing escape after you're done editing and :x. You don't have to restart anything, and you should be ready to to do commits in your relocated server! If you run into password issues because you have a new username/password, tell tortoise to delete the saved username/password. To do this: 

  1. Right-click your desktop and select TortoiseSVN->Settings.
  2. Select Saved Data.
  3. Click Clear against Authentication Data.

Step 7: Optional stuffs 

Make a dump of your current repository on your VisualSVN server for backup purposes. This will take many hours (my 30 gig repo took more than a day) but is the smart thing to do if you run into issues. 

Also, this is the *proper* way of migrating an SVN server, by making a dump, and then importing the dump into your new SVN server. Problem with this is that it will take FOREVER to do this. The dump route isn't necessary to make a working migration but, check here for a discussion about this.

To do a dump, on your windows machine running your VisualSVN server run a VisualSVN powershell (its a program that you have installed) and run the following command:

svnadmin dump C:\Repo\Dir > file_name_of_your_choosing.dump

Again, this will take hours/days depending on how big your repo is, and it'll also create a file much bigger than your repo. Good news is that it zips well and you can just zip it and leave it as a backup. This dump file can be imported in your Synology svn server by going to google and searching "svn dump repo import". 

One other thing is external access. If you want to access your SVN server from outside, use DDNS which is a painless thing to setup with the Synology software. 

ALSO, the ports shown here are the default ones. Do yourself  favor and CHANGE THESE to a random port. Especially the SSH and SVN ones. Your server is going to constantly be attacked by hackers who scan these ports and try to blast passwords at it. After setting up external SSH on my server it took ONLY 2 HOURS to get an email notification from the server that someone was trying to hack it and was automatically blocked. 

Hope this helps!