How to use svnsync in Windows environments
The solution provided in this article is not supported by Atlassian because it does not involve Atlassian products directly, this is considered third-party product integration.
It is recommended to use
svnsync in order to mirror remote repositories currently indexed via http/s protocol onto the Fisheye/Crucible server, so that you can access it with the file:// protocol and greatly increase the indexing speed.
svnsync link in our documentation redirects to Apache documentation which only has usage instructions for Linux hosts.
The purpose of this article is to provide a way to use
svnsync in Windows hosts.
svnsync command is part of Subversion, so you must have Subversion installed on the Windows machine running Fisheye, otherwise the
svnsync command will not be found in that server. Subversion can be downloaded from here.
After installing Subversion on the machine running Fisheye, please open a new Command Prompt and run
svnsync, just to make sure that the command is found. If it is found, you should see an output message saying
Type 'svnsync help' for usage.
After that, you should be able to follow steps similar to the ones from svnsync guide:
First, you need to create your destination repository in the Fisheye server. Let's suppose you want to mirror the repositories into a directory named
Using Command Prompt, go to
C:\Repositoriesand create an empty repository there. Let's say that the name of the repository is
Repo2Mirror. In that case, you should run a command like this:
C:\Repositories>svnadmin create Repo2Mirror
The command above will not output any messages, but the repository will be created.
Repo2Mirroryou'll see you have a
hooksdirectory. The files in this directory are Linux bash scripts and won't work in Windows hosts.
svnsyncprogram needs to store some special properties about its own synchronization activities. It does this by setting some properties on the repository at revision 0. In order to do this, there has to be a valid pre-revision property change hook on the repository that calls
This hook is also a perfect place to put your check that only a specific user (for example,
svnsync) is allowed to do things.
Please create a file named
C:\Repositories\Repo2Mirror\hookshaving the following content:
IF "%3" == "svnsync" (goto :label1) else (echo "Only the svnsync user can change revprops" >&2 ) exit 1 goto :eof :label1 exit 0
Feel free to change the username
svnsyncas you wish.
Go back to
C:\Repositoriesand run a command that follows this example:
C:\Repositories>svnsync init --sync-username svnsync file:///C:/Repositories/Repo2Mirror --source-username svnadminusr --source-password svnadminusrpwd http://examplecompany.com/svn/Repo2Mirror/ Copied properties for revision 0.
a) The username specified in
sync-usernameparameter is the one that will be validated by the
b) The URL
file:///C:/Repositories/Repo2Mirrorrefers to the empty repository created in Fisheye server
c) The username and password specified in
source-passwordshould be from a Subversion administrator user that has access to the entire tree of the remote repository
d) The URL
http://examplecompany.com/svn/Repo2Mirrorrefers to the remote repository you want to clone onto the Fisheye server.
Note: credentials for the source repository can be provided using
--source-passwordand for the destination using
--sync-password. These credentials are cached in the same way other credentials are cached.
C:\Repositories\Repo2Mirrorand run this command in order to start syncing (remembering to change the URL to mach the repository created in Fisheye server):
C:\Repositories\Repo2Mirror>svnsync sync file:///C:/Repositories/Repo2Mirror Committed revision 1. Copied properties for revision 1. Transmitting file data . Committed revision 2. Copied properties for revision 2. ...
- At this point, you should be able to add the synced repository in Fisheye using
file:///C:\Repositories\Repo2Mirroras Repository URL (with a special note the mixed slashes).
In some use cases Fisheye might report a
NonWritableChannelException error when trying to index the local repository created with
java.nio.channels.NonWritableChannelException com.cenqua.fisheye.rep.RepositoryClientException: java.nio.channels.NonWritableChannelException java.nio.channels.NonWritableChannelException: null
This error means that either Fisheye or Subversion needs write permission in the directory configured for indexing but just read-only permission is granted, which suggests there is a lack of permission in the file system causing this issue.
Following the example above, right-clicking on
C:\Repositories\Repo2Mirror, selecting the Properties menu, unmarking the Read-only flag and saving changes won't help: when the Properties panel is opened again the Read-only flag will be marked again.
The KB article SVN indexing fails due to NonWritableChannelException provides some possible resolutions.
This external webpage here explains how to prevent Windows from marking the directory as read-only again. In the local instance where the
NonWritableChannelException error was troubleshooted, all suggestions from the external webpage (instead of one by one) have been tried at once before trying to index the repository again in Fisheye, so it could be that not all suggestions given there need to be followed for fixing the error, but the fact is that Fisheye was able to index the repository.
Please note that some of the suggestions from the external webpage may result in lowering security on the server. Therefore, it is recommended to discuss about the implications of following those suggestions with your Windows administrator / security practitioner before modifying anything.
Some customers have been able to fix this issue by granting Fisheye to the network service account for the mirror repository folder.