hcoop-backup: Back up spamd directory specially.
authormwolson_admin <mwolson_admin@deleuze.hcoop.net>
Mon, 28 Jan 2008 07:24:48 +0000 (02:24 -0500)
committermwolson_admin <mwolson_admin@deleuze.hcoop.net>
Mon, 28 Jan 2008 07:24:48 +0000 (02:24 -0500)
hcoop-backup

index f5e1a1f..2dd4332 100755 (executable)
@@ -106,6 +106,33 @@ tar clpf - --ignore-failed-read --no-recursion -C / -T backupfiles | \
   ccrypt -k $KEYFILE -e | \
   catsync hcoop.backup.tar$COMPRESS_EXT.aescrypt
 
+
+# Acquire lock before messing with spamd
+COUNT=0
+LOCK=/var/local/lib/spamd/.lock
+while test -f $LOCK; do
+    sleep 2m
+    COUNT=$(expr $COUNT + 1)
+    if test $COUNT -eq 10; then
+        # Enough waiting.  Kill the process.
+        P=$(cat $LOCK) || :
+        test -n "$P" && kill $P || :
+        rm -f $LOCK
+        break
+    fi
+done
+touch $LOCK
+
+tar clpf - --ignore-failed-read -C / /var/local/lib/spamd | \
+  $COMPRESS_PROG | \
+  ccrypt -k $KEYFILE -e | \
+  catsync ../common.spamd.tar$COMPRESS_EXT.aescrypt.new
+rm -f $LOCK
+
+test -s ../common.spamd.tar$COMPRESS_EXT.aescrypt.new && \
+    mv ../common.spamd.tar$COMPRESS_EXT.aescrypt.new \
+       ../common.spamd.tar$COMPRESS_EXT.aescrypt
+
 vos listvol deleuze | \
   tail -n +2 | \
   head -n -3 | \