Scott Hanselman

Running a Subversion Server off your Windows Home Server

June 04, 2009 Comment on this post [22] Posted in Home Server | Subversion | Tools
Sponsored By

image Disclaimer - People have been injured and emotionally scarred listening to my technical tips. This may violate your terms of service. If your ISP calls your house and is mean to you, or if you lose all your personal data because of my tips, know that we never spoke. I don't know you. Seriously, who is this?! Stop calling!

I put most of my docs in Live Mesh, and I host must of my Open Source projects at CodePlex, but I have a bunch of code and presentations that usually just float around. Tweet Sandwich is a good example.

I decided I'd try to host a Subversion Server. I don't want to use the machine I host my blog on, as I want the data in my house. Since I already have this lovely Windows Home Server that's saved my marriage, I figured why not host it there?

1. Logging into your Home Server

If you want to install software on your Home Server (and they are headless usually - no monitor) you have to use Remote Desktop. From inside my house, I run "mstsc /console" or "mstsc /admin" from the Start | Run dialog, the connect to my machine called "Server."

2. Install Visual SVN Server

I usually download software to the desktop, ignore the "holy crap don't do this" warning (although be aware) then open an administrator command prompt and run the MSI from there. I downloaded and installed VisualSVN Server, which is the absolute easiest way that I know of to get Subversion (SVN) on Windows. I installed it on the machine on port 8443. That's not 443, but rather 8443. It's kind of like the secondary SSL port. I could put it anywhere, of course, but 8080 is to 80 as 8443 is to 443. It's easy to remember and less likely that your ISP would block it outgoing from your house. You can test if you have open ports with this online tool.

3. Chose Storage and Back It Up

Windows Home Server is a different beast as it supports a RAID-like storage system. You are NEVER supposed to put anything on the D: (Data) drive directly. Always access data through shares like \\server\svnwhatever.

Here's the only/most wonky part of this whole thing. If you have a better idea or you work for the Home Server team, let me know if this is dangerous and I'll update this part of the post.

I made a folder on the D: drive (against recommendations) called D:\repos and I told Subversion that was the place to put stuff. Then I made a new Share called \\SERVER\SVNBackup and set duplicate to true. Then, I installed the Windows 2003 Resource Kit in order to get the RoboCopy tool, and I copied RoboCopy to C:\windows so it's in the path.

Finally, I made a batch file that looked like this:

robocopy /mir d:\repos \\server\svnbackup

This "mirrors" the D:\repos folder to the \\server\svnbackup. I then used the "Add Schedule Task" wizard and made this run every night at 2am. This way I get backup and duplication in a nightly snapshot.

Alternatively, I probably could have mapped a permanent local Z:\ drive on the Home Server to \\server\svn or some share, and told VisualSVN Server to use that. However, that itself seemed wonky? My way seems to work. Thoughts?

image

4. Forward Port

I then logged into my local router and set up a port-forwarding rule to make sure that 8443 was accessible from the outside. Check your router or visit http://192.168.1.1 (usually) to figure it out.

5. Get an External DNS name (Optional)

You can certainly just visit http://www.whatismyipaddress.com and remember your address if you like. You can also hard-code it in your hosts file on the machine that will be your client.

You might consider using a service like DynDNS and get a custom domain like yourname.dyndns.org. There are applets that will run in the tray on your Windows Home Server and keep that IP address in sync if it changes.

Windows Home Server also includes options to get your own Home Server-provided domain under the "Settings" dialog in the Home Server Console. You can be http://foofoo.homeserver.com or a number of choices. This domain name is associated with your Windows Live ID and the IP is automatically updated by the Home Server.

imageNote, you can also log into your Home Server remotely, if you've enabled it. Here's me logging into my Home Server from elsewhere. Notice you can see what machines are online at home in the background there. I can RDP (Remote Desktop Protocol) into those machines if I like, and I can also remote into my Home Server itself.

Incidentally you can also view and download files from your shares, so choose strong passwords.

When you connect to your new Visual SVN Server instance over another port, your browser will likely complain that the certificate isn't trusted and it'll turn your Address Bar red and scary. Bummer, but be aware.

Now I can SVN Checkout https://mymagicdomain.homeserver.com:8443/svn/presentations/trunk as I please.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
June 04, 2009 4:50
If you were to map the network share to a drive letter, you could do away with having the repo folder directly on the D: drive. This is a lot easier to do with programs that run interactively though.

Perhaps a service could be made that runs as the same user as the SVN service and maps the drive letter before SVN starts. The SVN service could then be edited so that it depends on the drive mapping service.

Seems like it could work:
news group posting about services mapping drives
KB article about service dependencies
June 04, 2009 5:38
It was able to make a Windows service that maps drives letters and then successfully have VisualSVN save it's repos to it.

You also have to do the same mapping on the account you use to install VisualSVN.
June 04, 2009 5:41
Great Post. Love VisualSVN including there NOT free Visual Studio client which is VERY good.

I just wanted to point out that OpenDNS.com is a lot better than DynDNS all while being completely free.

Seth
June 04, 2009 5:55
Hi Scott,

There's a little trick to using VisualSVN Server with Home Server. During the install of VisualSVN Server you have to pick a local path for the repositories - leave it as the default C:\Repositories. Once it's installed, open the VisualSVN Server Manager, go to the properties of the server, and change the path to a share you've created on the Home Server like \\homeserver\svn.

The only catch I've found so far is that you need to allow guest read/write access to the share. Not sure if it would be possible to create a local user on the Home Server and run VisualSVN Server as that user.

This way you can enable duplication on the share for extra redundancy!

John
June 04, 2009 8:20
Hi Scott!

Uh, why not host the SVN Server on another machine on your LAN and just make sure that it's being backed up to the Home Server?

PS: I bought a Home Server based largely on your advice but I refuse to make it the accessibly server from outside my home. If I really need to get to it, I can remote onto my Vista box and then pull up the Home Server desktop or control interface. Don't see the need to make my Home Server directly hackable, I mean, accessible to the world.
June 04, 2009 9:16
Hi Scott,

Regarding the backing up of the svn repository.

As I understand it, you should not copy the repository directly, but instead you should you use

svnadmin hotcopy OLD_REPOS_PATH NEW_REPOS_PATH

(svnadmin should be in the directory where you installed VisualSVN)

Nadav
June 04, 2009 9:58
Scott,

It gets even better. Visual SVN has hidden on their web site instructions for integrating a Trac server with VisualSVN Serverhere. I've set this up myself, and it makes an awesome integrated system with SVN and defect tracking.

Steve
June 04, 2009 11:28
Great post - I have been doing something similar however got stuck when I wanted access to be over port 80 or 443 so it can be accessed from more restrictive lans with the existing IIS on that box handling the 80 and 443 traffic. Also keen to use the tortoise client

I reckoned on a reverse proxy (implemented as a httphandler in asp.net) however all the ones I found (e.g. the simple one on the codeproject site) did not handle the OPTIONS verb or pass on the useragent which is used heavily by Tortoise. Got to a state where tortoise hangs on an update and I think it was a header that was missing but ran into skillset issues (ahem... miine).

Is there a simpler / exisintg solution?

June 04, 2009 17:28
I second Nadav's recommendation; using robocopy (or copy, or xcopy) could mean your copied repository is corrupted.
June 04, 2009 20:00
Am I the only person left using SourceSafe?
June 04, 2009 20:39
Dave - I'm sorry. Yes, you are.
June 04, 2009 20:40
Richard - There's a guy at MSFT who has a small reverse proxy solution for EXACTLY this. I'll try to get him to release it.

Thanks for the hotcopy solutions, guys/gals!
June 04, 2009 20:42
Administering your own servers feels so 1990.

For an impossibly cheap price, you could create an account at a place like dreamhost and let them host the svn server for you. You also get web, mail, even a shell ... great uptime, updates, backups, etc, all taken care of for you.

I used to host my own Exchange at home and all that, then finally gave it up when I realized for that for almost no money I could use a hosted server with up-to-date spam stuff and entirely no administration load for me.

Hosted services are a much better option in my view.


June 04, 2009 21:12
Thanks for the heads up. I also have SVN hanging off my home server but allow for annonymous access. If you're reading this and wondering how to do it, please check it out.

http://www.pchenry.com/Home/tabid/36/EntryID/94/Default.aspx

I'm currently thinking about migrating all my SVN repository "stuff" to CodePlex, but until I get some spare cycles, the code will stay on my box.

Great read, thanks.
June 05, 2009 4:39
I am a sucker, I clicked on the SVN link in the blog.

You should send us the link for readonly access and share your presentations for the world to see.

Regards,

Roberto.
June 05, 2009 5:23
I like your idea. I use visualsvn and visualsvn server. It is very quick and reliable. who wants to deal with giant elephant (Opps..I mean TFS). I still use VSS at work and try to prototype elephant at home. Let me tell you giant sucked every single time.
June 05, 2009 14:03
I have been using Subversion for a while on my home server, doing a similar thing...
But as I wasn't using the VisualSVN 'goodness' I didn't have it secured using SSL - was just using svn:// on the default port...

Guess who will now be migrating to VisualSVN ;-)

..KJ
June 05, 2009 22:02
Scott, have you ever tried Mercurial?
Save yourself the horrors of setting up a Server and just have your central repository be on a network share.
Also you don't need to expose that home server repository to the web since you can clone the repository and work with it offline.

I made the move from SVN to mercurial some time ago and never regretted it:
http://www.tigraine.at/2009/05/30/moving-to-mercurial/

greetings Daniel
June 06, 2009 2:36
Scott,

Great writeup. I have been running SVN on a Windows 2003 server, but after reading this I might just give it a try on Windows Home Server.

The hosting company that I use provides a SVN repository, have you tried hosted SVN?

-Steve
June 11, 2009 19:28
Hi Scott, I mapped the network drive on the homeserver to a letter and used that... I have yet to verify if that actually does use the network path properly or if it cheats and uses the local drive letter though.
June 19, 2009 23:59
I figured I'd update this thread with a link to a tool I wrote that provides a Reverse Proxy for IIS so that you can access the subversion server thru the standard port 443 on IIS:

SVNReverseProxy at my Codeplex Project
August 25, 2009 10:47
Its always good to have a dedicated managed hosted server. Nice post.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.