Failed to get lock on destination repos

Subversion 1 Comment »

This error indicates that svnsync failed to release locks upon exit. You can release the locks with the command:

 svn propdel svn:sync-lock --revprop -r 0  svn://targetrepository
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Replicating a Subversion Repository to a Windows Target Server via Synchronization

Computing, Programming, Subversion 4 Comments »

To backup, replicate or mirror a repository is arguably one of the most important tasks working with Subversion. Of course a repository folder is completely self-contained and can be copied or ftped to a different location and read by svn without any problems as long as there is no writing or locking going on. Besides the simple copy there are several safer and more svn-specific options, three of which are discussed in this article. However, the suggested svnadmin hotcopy command like most svnadmin works only with paths, not URLs. So you have to enter (Windows):

C:\>svnadmin hotcopy c:\myrepos \\MYBACKUPSERVER\C\myrepos_bak

This technique works fine on your local network where you have path access as it’s fast and simple to use.

Since version 1.4 Subversion offers the svnsync utility which maintains read-only mirror of a subversion repository at a (remote) URL. It words by replaying revisions of the original (source/master) repository at a mirror (sink) repository.

The setup notes are meant for Unix machines and not easy to understand for newbies. Follow these steps to get it working on a Windows machine:

  1. Set up a sync user on the destination repository by editing the passwd file in the conf directory of the target repository:
    [users]
    #harry = harryssecret
    #sally = sallyssecret
    mysvnsyncuser = mystrongpassword
  2. This “syncuser” you created must be allowed to change revprops of the destination repository used by svnsync to keep track of bookkeeping information. Therefore a pre-revprop-change hook script has to be created. You will find an example script in the /hooks/pre-revprop-change.tmpl file of your target repository. However, this script is a Unix shell script and will not work under Windows. You will get the following error if you don’t have a script in the hooks folder that can be executed by Windows:

    svnsync: Repository has not been enabled to accept revision propchanges;
    ask the administrator to create a pre-revprop-change hook

    The simple solution is just to create a file named pre-revprop-change.bat containing the single line:
    @exit 0
    and save this file file in the /hooks directory of the target repository.

  3. Then svnsync has to be initialized with the command:
    svnsync init svn://mytargetserver/mytargetrepository svn://mysourceserver/mysourcerepository
    (you can use any other URL such as file:, http:, svn+ssh:)
    You will be prompted for the username and password you created for the mysvnsycuser above.
    If all went well you will get the response:
    Copied properties for revision 0
  4. You can now sync with the command:
    svnsync sync svn://mytargetserver/mytargetrepository
    and all revisions to your source repository will be replayed to the destination repository.
  5. In Windows you could set up a Scheduled Task to sync from time to time which is beyond the scope of this article.
  6. Don’t forget: NEVER commit to a synced repository without “svnsync” or you’ll get the “have you committed to the destination without using svnsync?” error and you’ll have to start over with the above process.

Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in