Is it possible to have multiple repositories for the same project?
I am currently using SVN with TortoiseSVN with the repositories on an external hard disk at my home, and well as regards a backup-wise solution, this isn’t ideal.
So what I have in my mind is making an account with unfuddle and having a second (my home one being the first) repository to where I can commit there (even for a remote-backup solution).
Now of course, I want integrity in my code and I don’t want discrepancies between the two (or more ?) repositories, which means that both repositories should be both updated when I commit my code.
So what can I do to make this happen?
Something I have in my mind is committing to my primary repository (the home one) and then it automatically commits to the online repository (the unfuddle one) automatically (because of course I don’t want to manually commit to both repositories every time I commit my code)
Is this possible ?
Everything’s possible 🙂
EDIT: haste never leads to quality nor did my answer, missing all the Windows references in the question. So here’s a run down on how to get the sync working on Windows.
You have 2 machines in this case:
Create a new repository on B that you wish to synchronise to from A. It’s very important that this repository is blank (running on rev0).
On B, in the SVN folder of the newly created repository, browse to /hooks and create the following BAT files:
start-commit.bat
pre-revprop-change.bat
someuserbeing a syncuser that exists in machine A’s repository and is the only user with rights in machine B’s repository. It’s very important no commits are done manually to machine B’s repository.In the
/hooksfolder of the repository on machine Apost-commit.bat
Once these batch files are in place we need to tell the repository on B we want to synchronise to it:
svnsync initialize svn://machineB/repos svn://machineA/repos --non-interactive --no-auth-cache --source-usernamemachineAusername--source-passwordmachineApassword--sync-usernamemachineBusername--sync-passwordmachineBpasswordwhich should return something like:
Copied properties for revision 0.Now every time you commit into the repository on machine A it will be copied over to machine B’s repository.
It’s very important to note that if you want to synchronise to Google Code or another online repository that they commit a trunk/branches/tags structure into revision 1. You have to contact them to reset the repository if you wish to use these third party repository location as the synchronisation repository.
To give credit where due I copied the pre-revprop-change.bat and start-commit.bat from http://www.svnforum.org/2017/viewtopic.php?t=5745&sid=06551a22d9c0b5780cf1faab6b0e8ce9
I just implemented this myself on a test repository and seems to work like a charm. I’m glad I noticed this question though svnsync has sunk too deep down in my skull. I meant to do set it up when setting up svn at work. So I know what the first thing is I’ll be doing at work tomorrow, thanks for that!
EDIT 2:
If you, like me, have tons of repositories this generic post-commit.bat might appeal to you:
This catches the repository name and uses it to dynamically determine the sync URL. I suffixed all my synchronisation repositories on machine B with
-syncfor clarity. TheD:\SVNbit is the svnserve root on machineB even though this generic BAT file should be placed in the /hooks of machineA‘s svnserve root.