Backups

Backing up darcs

While revision control ideally means that you can recreate any point in the development history of your project, it is sometimes comfortable to retain snapshots of the whole thing at regular intervals.

The simplest way is probably to just back up the _darcs directory. To restore a working copy, just unpack the appropriate _darcs and do a darcs revert.

Makefile

For simplicity of use, I’ve put the necessary commands in a Makefile in my home directory:

DARCS=`find . -name _darcs -type d | grep -v trash`
DATE=`date +%Y-%m-%d`

backup:
        tar jcf archive/darcs-$(DATE).tbz $(DARCS)

sync:
        rsync --rsh=ssh -av archive host.elsewhere.org:archive

Now make backup will find all darcs repositories, except any with the word trash in their name or path, and make sync will push it all to a remote computer, so that not all is lost when (and not if) the disk on my laptop breaks down.

Keeping unrecorded changes

The observant reader has probably noticed that any unrecorded changes will not be backed up. This is easily resolved by doing a darcs diff with output to a file, and including this file in the backup.

I’ll leave the exact commands and Makefile modifications as an exercise for the reader :-)

Questions

For a shared repository, or an automated backup process that accesses a live repository, is it correct to assume that one should make a temporary copy of the repository, using darcs, and then back that up in order to ensure a good snapshot of its state?