My dad's computer died about a fortnight ago. With it down, the SVN repository containing all my nerdish projects also went missing.
So, I took the opportunity to start fresh and rework the structure of my Subversion server.
I am going to set up my PC as the server, and store my repository on a remote FTP server online. Since my web host provides daily backups, I wont lose my projects anymore!
I would connect to my FTP server as a mapped network drive, and give it a drive letter. That way, I could treat it like a normal directory and it'd just work. Sweet!
The last time I set up SVN as a service, it was a walk in the park...
This time... "Its just an upgrade to the server, what could go wrong?"
So I downloaded SVN from the official site. You can select binary packages for either "Apache 2.0" or "Apache 2.2". (In case you're wondering, download the binaries with the filename similar to "svn-win32-1.5.4.zip")
Personally I dont really care as I dont integrate it with Apache, but its best to pick the version which matches in case you change your mind later down the track.
Extract the contents of the file to where you want SVN to be installed.
For me, I set it up at "C:\Server\svn".
Add ";C:\Server\svn\bin" to your %PATHS% environment variable.
To do that, right click "My Computer" > "Properties" > "Advanced" > "Environment Variables".
Select "Path" from the "System Variables" list and append the string.
Creating a service
Before typing up the commands, be sure to note that the syntax requires a space AFTER the "=" sign. I don't know why Microsoft decided upon that syntax, its stupid.
[ Source ]
To install svnserve as a native Windows service, execute the following command (all in one line).sc create subversion binpath= "C:\Server\svn\bin\svnserve.exe --service --root Z:\svn_repository" displayname= "Subversion" depend= tcpip start= auto
If any of the paths include spaces, you have to use (escaped) quotes around the path, like this:sc create subversion binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root C:\ServerFiles\svn_repository" displayname= "Subversion" depend= tcpip start= auto
A breakdown of the command arguments is shown below.
- "sc create subversion"
Creates a service named "subversion".
- "binpath= "
The executable file.
Run it within the Windows native service wrapper.
- "--root= "
The root folder for repositories.
- "displayname= "
A nice name for the service in the Service Manager.
- "depend= "
Dependencies for this service.
- "start= "
The starting method.
If you typed something wrong, type "sc delete subversion" to delete the service and start again.
Once created, type "net start subversion" to start it.
If you encounter any error messages, refer to "the problem" section later in this post.
Creating a repository
As I have chosen "Z:\svn_repository" as the root repository folder, thats where all the repositories should be created.
To create a new repository, type "svnadmin create "Z:\svn_repository\new_repository_name""
Using an SVN client (I prefer to use TortoiseSVN), check out a copy of the repository by entering "svn://localhost/new_repository_name" as the location.
Once you've tested your repository and know it works, modify the "svnserve.conf" file to disallow anonymous read access by adding the line "anon-access = none" under "[general]".
Also, uncomment the use of the password file where it says "password-db = passwd".
Edit the "passwd" file and give yourself an account.
Sometime between v1.4 and 1.5, the folks at SVN decided to add native Windows service support to "svnserve.exe".
[ Notable sources: Source 1, Source 2 ]
Although this may seem great, it makes life horrible for people who want to stash their repository on a mapped network drive. Services, by default, are run on the account "NT Authority\Local Service", which has no access to mapped network drives.
When trying to start the service from the Service Manager, I kept getting an error message.
Error 1053: The service did not respond to the start or control request in a timely fashion.Spent a good few hours learning that lesson.
Great, there goes my initial idea.
Up until now its been smooth sailing.
I've tried running as my current login, giving it a password, changing to interact mode, switching to "NT AUTHORITY\NETWORK SERVICE" account and so many other little things that its caused me so much mental distress that my mind choses not to remember. They all failed.
Luckily, all that research didn't go to waste as I discovered an alternative, which is to access the FTP via a UNC pathname.
[ Crosspost: How to configure WebDrive ]
So rather than using "Z:\svn_repository", I configured the FTP server to a UNC path "//uncpath/home" using WebDrive.
The command to create a sevice becomes...
sc create subversion binpath= "C:\Server\svn\bin\svnserve.exe --service --root //uncpath/home/svn_repository" displayname= "Subversion" depend= tcpip start= autoNow my SVN server runs off my home PC and stores the files onto the remote host via FTP.
In the wise words of Jeremy Clarkson, "SWEEEEEEEET!"