]> git.sesse.net Git - backup.sh/blobdiff - backup.sh
Do not try to get .incremental.snar if we did a date-based backup.
[backup.sh] / backup.sh
index 0e230399b4ed6be81fe2767139520ce439642e49..48307bc92ad3b81c994b3aa3b6d3920019b216be 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -114,9 +114,11 @@ backup()
 
        if [ $? -eq 0 ] && [ -s $TARFILE ]; then
                # File is >0 in size and neither cat or tar tzvf failed; we assume it worked.
-
-               if ! scp root@$computer:$incrementalsnar $SNARFILE.tmp; then
-                       diemsg "Could not copy .incremental.snar from $computer"
+               if [ "$incrementalsnar" ]; then
+                       if ! scp root@$computer:$incrementalsnar $SNARFILE.tmp; then
+                               diemsg "Could not copy .incremental.snar from $computer"
+                       fi
                fi
 
                # Move tar file in place
@@ -202,8 +204,7 @@ if ! ssh root@$computer "[ ! -f /root/.backup/preexec ] || /bin/bash -x /root/.b
        diemsg "Could not run $computer:/root/.backup/preexec"
 fi
 
-for filesystem in $filesystems
-do
+for filesystem in $filesystems; do
        # Remove / and $ (for Windows) for path names
        sfilesystem=`echo $filesystem | tr '\/\$' '__'`
 
@@ -247,15 +248,16 @@ do
        backup
 
        # Check if this box has a custom number of full backups
-       if [ -f $confdir/maksfulle.$computer ] ; then
+       if [ -f $confdir/maksfulle.$computer.$sfilesystem ]; then
+               mf=$((`cat $confdir/maksfulle.$computer`+1))
+       elif [ -f $confdir/maksfulle.$computer ] ; then
                mf=$((`cat $confdir/maksfulle.$computer`+1))
        else
                mf=$(($maxnumfull+1))
        fi
 
        # Delete old full backups
-       for full in `ls -1t $storagedir/$computer/$sfilesystem/full/*tgz | tail -n +$mf`
-       do
+       for full in `ls -1t $storagedir/$computer/$sfilesystem/full/*tgz | tail -n +$mf`; do
                prefix=`echo $full | sed "s/\.[^.]*$//"`
                echo `date`": $computer:$filesystem Deleting full backup $prefix" >&2
                rm $prefix*