Efficient way to backup maildirs from post-sync hook?
snhmnd at gmail.com
Sun Mar 6 12:19:24 GMT 2011
I'm trying to use offlineimap's postsynchook to run a command to
incrementally backup my local maildirs. This seemed like a good place to
do the incremental backup as it will be called after every sync (if the
backup is run any less frequently there is a risk of losing mail), and
it lets me just use the offlineimap command as usual instead of having
to use my own script that runs offlineimap and then a backup command or
something like that.
The problem is that I can't find a way of incrementally backing up the
maildirs that is reasonably fast and easy on system resources.
I wouldn't want to run rsync with the --delete option as this would
defeat the point, an email accidentally deleted from the live copy would
get deleted from the backup. But without --delete I think rsync might
duplicate a lot of mails, for example I often delete mails from my inbox
maildir and move them into a trash or archive maildir, and I think rsync
would duplicate these (ie the backup would contain two copies of the
same mail). I got rsync to work using the --link-dest option, this way
each incremental backup contains hardlinks to files in the previous
backup for all the files that haven't changed, any new or modified files
are copied into the new backup, any deleted files are left out of the
new backup. This works, but it takes a very long time to execute, I
guess because it has to compare a lot of files in the live maildirs to
files in the backup, and it has to create a lot of symlinks.
I also tried using the version control system git. This works and is a
lot faster than rsync, but it still takes too long and too much system
resources, bringing my desktop PC grinding to a halt.
With either of these backup hooks offlineimap takes several times longer
to sync my three mail accounts than it would without.
Does anyone know a faster way of doing this?
More information about the OfflineIMAP-project