Mon Apr 30 18:38:00 UTC 2007

Backing up a Subversion Repository

Posted in SubVersion at 06:38 PM by mohits

The simplest way to back up a Subversion repository is to make a full backup of it. If your repository is very large, then this may be a bit of a slow process and there are other ways which can be used. However, if you are just looking for the simplest way to ensure that you have a simple backup of your precious repository, then the instructions are very simple!

Backing up

Especially if you use the BDB backend, it is important that you do not access or copy the repository directly. If someone accesses the repository for anything at this time, your backup will be corrupted and quite useless. Therefore, you need to use hotcopy option of the svnadmin command. This ensures that you get a proper comprehensive snapshot irrespective of people accessing the repository at the same time.

More importantly, though, there is a simple Python script called hot-backup that takes as inputs the path of the repository and the path of the backup directory and does the rest. If you have Python installed, this is the easiest way.

  1. Download the script
  2. Change the name to hot-backup.py
  3. Open it in a text editor and change the first line to the directory where Python is installed. In my case, this is #!C:\Python24
  4. Update the paths to ‘svnlook’ and ‘svnadmin’ further down in the script. In my case, these were changed to: svnlook = "C:/DevSupport/Subversion/bin/svnlook" and svnadmin = "C:/DevSupport/Subversion/bin/svnadmin".
  5. Save the script to a directory of your choice. I saved it to: c:\DevSupport\SubVersion\tools\backup
  6. Run it from the command line giving it the repository and backup paths.
 D:\Repository>c:\DevSupport\Subversion\tools\backup\hot-backup.py D:\Repository\svn\Project D:\Repository\backup
 

After you run this, in the backup directory, you will see a new directory created having the same name and revision number as the project name and version it backed up. For example, you may get something like Project00-4 which means that this is revision 4 of Project00.

Restoring

The copy that is made is a copy of the entire repository and is actually a fully working repository and can be used just like any other repository. There is no special procedure to restore a backup.

Links

This topic has been written about quite a bit and you will find quite a bit if you search Google.

  • Refer to Repository Management in the ‘official’ SVN book for more details.
  • This article helped me get started (I just made minor modifications to get it working on Windows)
  • Finally, this article talks about the dump and load commands that can also be used for backing up, migrating and restoring repositories.

Mon Apr 30 18:25:00 UTC 2007

Running svnserve as a Windows Service

Posted in SubVersion at 06:25 PM by mohits

It took me a while to assemble this information about what needs to be done to run svnserve as a Windows service and since I shall need this information in another few days when I set it up on a different server, it made sense to link it here.

Background

svnserve allows you to connect remotely to an SVN repository over a network. In these cases, the repository names are something like “svn://server/project” and this is regarded as one of the easiest ways to connect over a network. This method is usually recommended for corporate LANs where you are confident that your communication is safe from snooping. There are other ways such as ssh + svn which can offer greater security, but I digress.

If you decide that svnserve will work for you and you have svn running on a Windows computer, then you may want to run it as a service. That way, it can be made to start up automatically when the computer restarts (as it will every now and then if it has just installed a bunch of updates automatically) and is generally easier to manage.

What needs to be done?

Basically, the latest svnserve already has everything that is needed to run it as a service. All you need to do is install it as service by passing it the correct options. Let’s assume that you have the following settings:
  • Subversion Installation: C:\DevSupport\Subversion
  • Repository: D:\Repository

If this is the case, you need to go to a Command Window (Start Key> Run> cmd [enter] >) and run the command SC.exe to interact with the service manager. You could type sc.exe to see how it works and what it expects from you.

For the impatient, this is what you need to type in at the command prompt to register svnserve as a service.

C:\>sc create svn_repos binpath= "C:\DevSupport\Subversion\bin\svnserve.exe --service --root D:\Repository" displayname= "Subversion Repository" depend= Tcpip


There a few things to note here:

  1. Options to sc create must have the equal-to sign stuck to the option name (it’s part of the option name) and there must be one space after it. So, depend= Tcpip is correct and depend = Tcpip, depend=Tcpip and depend =Tcpip are all wrong.
  2. The display name is what it will show up as in the Service Manager. You can set it to whatever you like.
  3. The binpath is the actual command line that will be called. Note that the option to run it as a service is --service and no other option works. It must be --service if it is to work.

Do I need one service for each repository?

In short, No. The command line option to svnserve only identifies a root directory which will be served up. The repository can be in any directory below it.

Suppose that your repository looks something like this:

D:\Repository
  |
  |- Project 1
  |
  |- Project 2
  |
  |- Project 3

and you use the above to serve it up, then the URLs for accessing the 3 projects from a Subversion client will be:

Project1 - svn://server/Project1
Project2 - svn://server/Project2
Project3 - svn://server/Project3

So, basically, if the individual project repositories are under the same root directory, you do not need a separate service. You will need a separate service for each root directory because I don’t think that a single svnserve service can handle multiple root directories.

How do I make it automatically start upon reboot?

The steps above will only ensure that the service is installed. If you want the service to start, you need to do a couple of other things.

  1. Go to the Service Manager (Start Button> Run> services.msc [enter])
  2. Find the service you just installed (if you called it Subversion Repository, then that will be the service name)
  3. Right-click on the name of the service and select properties.
  4. If the service is not running, start it by clicking on ‘Start’
  5. Change the start-up type to ‘Automatic’
  6. Click on ‘Apply’ or ‘OK’ and exit the page.

The service is now running and will be automatically started every time Windows is restarted.

Refer to this note for all the gory details.

Mon Apr 30 17:22:00 UTC 2007

svn:ignore for Visual Studio and Codegear Turbo C++

Posted in Codegear Builder | Turbo C++, SubVersion at 05:22 PM by mohits

I have just gone through setting up Subversion and was looking at which directories and files need to be ignored by the client when it uploads the project. I expect that I shall need to set these properties for every project that I work with, so I decided to put up the list here so that it’s easy to find it the next time I need it. If it helps you, that’s a bonus :)

If you are using TortoiseSVN, you can set these properties by right clicking on the name of your project sandbox directory and then following the TortoiseSVN>Properties. In the form that pops up, click on “Add” and for property name, select “svn:ignore” from the drop down list. Then, in the memo field, just copy and paste the set of files to ignore. Check “Apply property recursively” to apply it to all directories.

Visual Studio 2005

*.obj *.exe *.pdb *.ncb *.res *.pch *.idb

In addition, you can also ask it to ignore the directories in which it creates the executable code. Since I’m using Visual Studio for Windows Mobile development, this will usually be a directory such as “Pocket PC 2003 (ARMV4)” which will have files that are created during the build process. When you do your first “Commit” with these directories there, just right click on each of the directory names in the TortoiseSVN list and ask it to ignore it.

Turbo C++ Professional

*.obj *.~* *.dsk *.d *.local *.bcc32pch *.res *.tds *.exe *.bbc *.bbd *.bbl *.bbp

In addition, you can also ask it to ignore the directories in which it creates the executable code. Since I’m using Turbo C++ for Windows PC development, this will usually be a directory such as “Debug_build” and “Release_build” which will have files that are created during the build process. Also, you can ask it to ignore the “__history” directory if you don’t care about the revisions that Turbo C++ maintains. When you do your first “Commit” with these directories there, just right click on each of these directory names in the TortoiseSVN list and ask it to ignore it.