X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmaildir;h=a729a3aab17e06f6d561b801a51faa3f9f135156;hb=0d606253af6ecb8ede07b0991a1f295fb70e7e65;hp=6da5c0f08f5a7c6baf76283156d302a21e8da864;hpb=b808ac3de7a5abc0b8b6fd1409ba397056b3c56b;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/maildir b/handlers/maildir index 6da5c0f..a729a3a 100644 --- a/handlers/maildir +++ b/handlers/maildir @@ -1,3 +1,4 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- ############################################################### # # This handler slowly creates a backup of each user's maildir @@ -12,7 +13,17 @@ # weekly.2 # monthly.1 # if keepdaily is 3, keepweekly is 2, and keepmonthly is 1. -# +# +# The basic algorithm is to rsync each maildir individually, +# and to use hard links for retaining historical data. +# +# We rsync each maildir individually because it becomes very +# unweldy to start a single rsync of many hundreds of thousands +# of files. +# +# For the backup rotation to work, destuser must be able to run +# arbitrary bash commands on the desthost. +# ############################################################## getconf rotate yes @@ -85,7 +96,9 @@ function do_user() { --exclude '.Trash/*' --exclude '.Mistakes/*' --exclude '.Spam/*' \ $dir $destuser@$desthost:$destdir/$letter \ 2>&1` - if [ $? != 0 ]; then + ret=$? + # ignore 0 (success) and 24 (file vanished before it could be copied) + if [ $ret != 0 -a $ret != 24 ]; then warning "rsync $user failed" warning " returned: $ret" let "failedcount = failedcount + 1" @@ -99,8 +112,8 @@ $dir $destuser@$desthost:$destdir/$letter \ # and add new ones which have just been created. function do_remove() { - local tmp1=/tmp/maildirtmpfile$$ - local tmp2=/tmp/maildirtmpfile$$ + local tmp1=`maketemp maildir-tmp-file` + local tmp2=`maketemp maildir-tmp-file` for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do ls -1 "$srcdir/$i" | sort > $tmp1 @@ -241,11 +254,11 @@ function setup_remote_dirs() { fi if [ -d $destdir/$backuptype.2 ]; then echo "Info: updating hard links to $dir.1. This may take a while." - cp -al $destdir/$backuptype.2/. $dir.1 - if [ \$? == 1 ]; then - echo "Fatal: could not create hard links to $dir.1 on host $desthost" - exit 1 - fi + cp -alf $destdir/$backuptype.2/. $dir.1 + #if [ \$? == 1 ]; then + # echo "Fatal: could not create hard links to $dir.1 on host $desthost" + # exit 1 + #fi fi fi [ -f $dir.1/created ] && rm $dir.1/created