change the date format for the deleted timestamp
[matthijs/upstream/backupninja.git] / handlers / maildir.in
index 4b98debfbef9f26acbe82bd14ad1cd3587356b27..7f2fba7d03b8d0a9ba538db6e9cdc92e1aab9824 100644 (file)
@@ -52,20 +52,20 @@ getconf destuser
 
 getconf multiconnection notset
 
-letters="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"
+letters="0 1 2 3 4 5 6 7 8 9 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"
 failedcount=0
 # strip trailing /
 destdir=${destdir%/}
 srcdir=${srcdir%/}
 
-# used for testing
-#getconf testuser elijah
-
 [ -d $srcdir ] || fatal "source directory $srcdir doesn't exist"
 
 [ "$multiconnection" == "notset" ] && fatal "The maildir handler uses a very different destination format. See the example .maildir for more information"
 
-[ ! $test ] || testflags="--dry-run -v"
+if [ $test ]; then
+   testflags="--dry-run -v"
+fi
+
 rsyncflags="$testflags -e 'ssh -p $destport' -r -v --ignore-existing --delete --size-only --bwlimit=$speedlimit"
 excludes="--exclude '.Trash/\*' --exclude '.Mistakes/\*' --exclude '.Spam/\*'"
 
@@ -111,13 +111,14 @@ function do_remove() {
        local tmp2=`maketemp maildir-tmp-file`
        
        ssh -p $destport $destuser@$desthost mkdir -p "$destdir/deleted"
-       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
+       for i in 0 1 2 3 4 5 6 7 8 9 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
                ssh -p $destport $destuser@$desthost ls -1 "$destdir/$i/" | sort > $tmp2
                for deluser in `join -v 2 $tmp1 $tmp2`; do
                        [ "$deluser" != "" ] || continue
                        info "removing $destuser@$desthost:$destdir/$i/$deluser/"
                        ssh -p $destport $destuser@$desthost mv "$destdir/$i/$deluser/" "$destdir/deleted"
+                       ssh -p $destport $destuser@$desthost "date +%c%n%s > '$destdir/$i/$deluser/deleted_on'"
                done
        done
        rm $tmp1
@@ -157,7 +158,7 @@ function do_rotate() {
                fi
                
                # Rotate the current list of backups, if we can.
-               oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
+               oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
                #echo "Debug: oldest \$oldest"
                [ "\$oldest" == "" ] && oldest=0
                for (( i=\$oldest; i > 0; i-- )); do
@@ -201,7 +202,7 @@ function do_rotate() {
        for rottype in daily weekly monthly; do
                max=\$((keep\${rottype}+1))
                dir="$backuproot/\$rottype"
-               oldest=\`find $backuproot -type d -maxdepth 1 -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
+               oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
                [ "\$oldest" == "" ] && oldest=0 
                # if we've rotated the last backup off the stack, remove it.
                for (( i=\$oldest; i >= \$max; i-- )); do