views:

236

answers:

3
+3  Q: 

Mercurial Backup

How could I enable automatic (incremental) backups of a Mercurial (central/main) repository?

I'm coming from subversion where I was able to make a commit-hook that uploaded changes to S3.

Edit: If this sort of strategy doesn't make sense for Mercurial, what backup strategy would make sense?

+1  A: 

you could do it is a similar way (commit hook to backup your repo somewhere) or you could just simply have a remote repository and push to it (or push on commit).

lastly if you are sharing your code withothers you have the added advantage that all of their repos can be used as additional backups, unlike in SVN where their working copy would conatin just a single snapshot.

jk
A: 

The beauty of how simply the DVCS's store history is that you can do this in a million different ways. You could write a commit hook, but I found it easier to just do it manual push + cron.

My simple and most likely naive approach:

I push to my central repository. My backup server pulls from the central repository every 10 minutes. Every day at 2:30am the central repository gets gzip'd and downloaded to the backup server. When I boot up my local machine I download the latest gzip backup and if I cared enough I could burn those to a CD.

So at any given moment I have at least 3 fairly recent backups and 3 recent working copies stored at different locations around the continent. If all of these fail I will be more worried about the rise of skynet then that I lost my project.

mfperzel
A: 

I found this answer somewhere on the Internet. Would it work? Could this be turned into a commit hook?

check out hg bundles --base. write a little script/extension that keeps track of the last hash id it was run on, and then pass that to --base, update the hashid, and so on ....

Adam Tegen