views:

152

answers:

2

Hi Guys,

Can anybody tell me how to setup a mirror of a mercurial repository? I have a mercurial repo on my laptop, but want to auto mirror the repo on a nas drive as a form of backup. Ideally, it would be cool if the solution checks a known location for a repo, and if one doesn't exist, create it, and from then on mirror any changes.

Another thing to bare in mind is that the NAS may not always be available, so would need to acomodate this in some way.

Many thanks

Matt

+1  A: 

Mercurial gives you the freedom to do that however you would like. If you wanted, you could just setup a process to copy the repo from your local machine to the NAS at a regular interval. Everything about the repo is stored in the directory, and everything in the directory is just a file.

However, it sounds to me like you want to setup something more akin to a version control system like Subversion. I do something like this with one of my projects (actually, I moved it from SVN to Mercurial, but that's a different answer).

I have a repository on xp-dev.com and my local repository on my computer. I do all of the work on my local repository I want to do, issuing hg com very frequently. When I am done for the day/night I do a hg push ssh://hg2.xp-dev.com/myrepo to send all of my local changes to the remote server.

So, really all you want to do is an hg push to put your local repo on your NAS and then remember to do it again on a regular basis.

jsumners
A: 

I did something similar with git, but all the functionality should be in mercurial too.

I created manually a clone on some server (in my case a VPS somewhere on the net in case my house burns down with NAS and laptops in it).

With git you can create a "naked" repository, i.e. w/o a branch checked out.

Then I regularly push to it.

This can be automated using 'hooks', more info here .

The trick is to get the handling off the commit hook (oun intended) and that the syncing is not in your workflow. Run your push script using the 'at' command in a couple of minutes time. Then it runs asynchronously in the background. I would not be fancy here, try and handle failures gracefully.

You now have a setup which will keep the backup synched within a couple of minutes.

Peter Tillemans