开发者

Setting up a mercurial mirror

开发者 https://www.devze.com 2023-01-03 09:44 出处:网络
Can anybody tell me how to set up 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 co

Can anybody tell me how to set up 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 bear in mind is that the NAS may not always be available, so I would need to accomodate this in some way.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消