]> git.sesse.net Git - backup.sh/commitdiff
Deal with nice and/or ionice not existing on the target system.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 15 Oct 2016 08:46:42 +0000 (10:46 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 15 Oct 2016 08:46:42 +0000 (10:46 +0200)
backup.sh

index 4ae63a364069e0968c5853ab61e47f4f1b045d31..71ebfe1084897fe525dd14091340d4c100a74ccb 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -128,7 +128,7 @@ backup()
        #    Pipe the stuff over ssh to ourselves, run pee to cat the contents to a
        #    file and build a file list, respectivly.  
        TARFILE=$DATE.tmp
-       TARCMD="ssh -n $username@$computer \"nice -n 19 ionice -c3 tar --one-file-system --use-compress-program $compressor -cf - -C $filesystem . $lastcmd \
+       TARCMD="ssh -n $username@$computer \"$nice tar --one-file-system --use-compress-program $compressor -cf - -C $filesystem . $lastcmd \
                --exclude-from=$remotehome/.backup/exclude\" | pee \"$storageprogram > $TARFILE\" \"tar tzvf -\""
        infomsg "Running $TARCMD"
        eval $TARCMD > $DATE.idx
@@ -246,6 +246,14 @@ else
        compressor=gzip
 fi
 
+# Check if nice and ionice are available
+if ssh -n $username@$computer "nice -n 19 ionice -c3 /bin/true 2>/dev/null"; then
+       nice="nice -n 19 ionice -c3"
+else
+       infomsg "nice and/or ionice missing; will run at normal priority."
+       nice=""
+fi
+
 # Check dump bit in fstab
 filesystems=`ssh -n $username@$computer "cat /etc/fstab" \
        | grep -v nfs \