1) Modified main.cpp to save backup db to a tmp file.
[backups/.git] / scripts / pack-image.sh
index 9a06f718bfb72a24ea7fbe691de98b40a36fa6bd..4f9c8287c1dc009e8e269dbf77bd45ebcfc93cf0 100755 (executable)
@@ -57,13 +57,12 @@ echo "-> Running find to get the status of files"
 {
   for type in d f l; do
     findformat="$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0"
-    if [ -z $excludeddirs ]
+    if [ -z $excludedirs ]
     then 
       find $backupdirs -type $type -printf "$findformat"
     else
-      regex=`echo $excludedirs | sed -e 's/ /.*\\\\|/g'`
-      regex=`echo "'\($regex.*\)'"`
-      find $backupdirs -type $type -o -regex $regex -prune -o -printf "$findformat"
+      echo $excludedirs | sed -e 's/ /\n/g' > $tmpdir/excluded
+      find $backupdirs -type $type -printf "$findformat" | grep -z -v -f $tmpdir/excluded
     fi
   done
 } > $currentfiles
@@ -81,11 +80,12 @@ cat $backups | rsync $rsyncopts / $isomountdir
 if [ $? != 0 ]
 then
   umount $isomountdir
-  rm -rf $isomountdir $isoimage
+  rm -rf $isomountdir $isoimage $backupdb.tmp
   err "Unable to rsync to pack the image"
 fi
 
 echo "-> Copying over database and status file"
+mv $backupdb.tmp $backupdb
 cp $statusfile $backupdb $restorescript $isomountdir
 
 [ $? != 0 ] && err "Unable to copy the database and status file"