[debian-lan-devel] [SCM] Debian-LAN development and packaging branch, master, updated. 0.6-39-gd9e2caa

Andreas B. Mundt andi at debian.org
Sun Sep 9 15:04:47 UTC 2012


The following commit has been merged in the master branch:
commit d9e2caa33a2f5373e340e6e9ec76bd11c02f94f5
Author: Andreas B. Mundt <andi at debian.org>
Date:   Wed Sep 5 11:26:20 2012 +0200

    Use dirvish to backup LDAP, package- and debconf-selection.
    
    Backups should expire after some time.  To use dirvish's expire
    mechanism also for LDAP data, package- and debconf-selection, a daily
    snapshot is dropped into a directory which is in turn backed up by
    dirvish.

diff --git a/fai/config/files/etc/cron.daily/backup/SERVER_A b/fai/config/files/etc/cron.daily/backup/SERVER_A
index 92aa8fb..46e369f 100755
--- a/fai/config/files/etc/cron.daily/backup/SERVER_A
+++ b/fai/config/files/etc/cron.daily/backup/SERVER_A
@@ -7,9 +7,7 @@
 set -e
 
 DIR="/backup/"
-LDIF_DIR="${DIR}/ldap/"
-DPKG_DIR="${DIR}/dpkg/"
-DATE=`date +%F`
+MISC_DIR="${DIR}/tmp/misc/"
 
 # from dirvish:
 mount_check() {
@@ -45,26 +43,28 @@ if grep -q ${DIR%/} /etc/fstab ; then
     trap "rc=$?; umount $DIR; exit $rc" ERR
 fi
 
-## backup ldap:
+## Backup LDAP, package selection and debconf data.
+## Drop the data in $MISC_DIR and use dirvish for
+## the backup, thereby making use of its expire
+## mechanism:
 if [ -x /usr/sbin/slapcat ] ; then
-    if [ ! -d $LDIF_DIR ] ; then
-        mkdir -p $LDIF_DIR
-	chmod 750 $LDIF_DIR
-    fi
-    slapcat -l $LDIF_DIR/$DATE.ldif
-    gzip -f    $LDIF_DIR/$DATE.ldif
+    slapcat -l $MISC_DIR/LDAP.ldif_new
 fi
+dpkg --get-selections  > $MISC_DIR/package.selection_new
+debconf-get-selections > $MISC_DIR/debconf.selection_new
 
-## backup package selection and debconf data:
-if [ ! -d $DPKG_DIR ] ; then
-    mkdir -p $DPKG_DIR
-    chmod 750 $DPKG_DIR
-fi
+## Check if the data has changed, if not keep the old file:
+for FILE in `ls $MISC_DIR/*_new` ; do
+    if diff -qN $FILE ${FILE%_new} >/dev/null ; then
+	## nothing changed:
+	rm $FILE
+    else
+	## use new file:
+	mv $FILE ${FILE%_new}
+    fi
+done
 
-dpkg --get-selections > $DPKG_DIR/$DATE.dpkg
-gzip -f    $DPKG_DIR/$DATE.dpkg
-debconf-get-selections > $DPKG_DIR/$DATE.debconf
-gzip -f    $DPKG_DIR/$DATE.debconf
+chmod 640 $MISC_DIR/*
 
 ## dirvish:
 if [ ! -x /usr/sbin/dirvish-expire  ]; then exit 0; fi
diff --git a/fai/config/scripts/SERVER_A/70-dirvish b/fai/config/scripts/SERVER_A/70-dirvish
index 5dd9521..e431bd0 100755
--- a/fai/config/scripts/SERVER_A/70-dirvish
+++ b/fai/config/scripts/SERVER_A/70-dirvish
@@ -4,10 +4,11 @@
 
 set -e
 
-## all backed up directories:
-BANK_DIRS="/etc /srv/fai/config /root /lan/mainserver/home0"
-
 BACKUP_DIR="/backup/"
+MISC_DIR="${BACKUP_DIR}/tmp/misc/"
+
+## all backed up directories:
+BANK_DIRS="/etc /srv/fai/config /root /lan/mainserver/home0 $MISC_DIR"
 
 fcopy -v /etc/cron.daily/backup
 rm -vf   $target/etc/cron.d/dirvish
@@ -42,6 +43,8 @@ EOF
 ## Do the following only once when installing,
 ## as /backup might not be mounted in general:
 if [ $FAI_ACTION == "install" ] ; then
+    mkdir -vp $target/$MISC_DIR
+    chmod 750 $target/$MISC_DIR
     for DIR in $BANK_DIRS ; do
 	ID=`basename $DIR`
 	echo "Creating dirvish config $ID for $DIR."

-- 
Debian-LAN development and packaging



More information about the debian-lan-devel mailing list