Question: Is there a way to back up a mercurial repository while preserving the files' timestamps?

Right now, I'm using `hg clone` to copy the repository to a staging directory, and the backup program picks up the files from there. I'm not pointing the backup program directly at the repository because I don't want it to be changing (from commits) while the backup is happening.

The problem is that `hg clone` changes all the files' timestamps to the current time, so the backup program (which I cannot change) thinks everything has been modified.

Answer: 
**Plan A:** When the source and destination directories reside on the *same file system*, `hg clone -U` would simply hardlink all its files in the repository, without changing timestamps. This approach is quite fast and always safe (files are unlinked lazily when written to).

If you need to, you can clone on the same file system first, and then rsync this new clone over to another file system.

**Plan B:** It's *usually* safe to use rsync or some other file-based synchronization tool. Mercurial doesn't store anything magical on disk, just plain files.

There is a race condition, when you happen to commit to this repository at the same time when rsync is running, but I think it's negligible because a "`hg rollback`" should be able to clean up your such inconsistencies if you restore from a broken backup. Do note, that rollback *cannot* recover if you had multiple separate transactions (such as multiple "push" or "commit" commands) in the rsync window, or run destructive operations that tamper with history (such as rebase, `hg strip`, and some MQ commands).
Here's a hg extension that might help: [TimestampExtension](https://www.mercurial-scm.org/wiki/TimestampExtension).