From 2d0f32547efdc040cd047668e9c3fb18b3adf046 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 4 Oct 2014 23:22:50 +0200 Subject: [PATCH] Use pigz if it is available, for less CPU-bound operation. --- backup.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backup.sh b/backup.sh index 652b463..a6ebade 100755 --- a/backup.sh +++ b/backup.sh @@ -89,17 +89,17 @@ backup() exf=`ssh root@$computer "ls ~/.backup/exclude"` # We try to run tar on the remote computer - # z gzip it # c create archive # C change to directory first # . where to start taring (see C) # $lastcmd only files newer than this # --one-file-system don't traverse file systems + # --use-compress-program compress it using gzip or pigz # --exclude-from file to get exclusion pattern from # 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 root@$computer \"nice -n 19 ionice -c3 tar --one-file-system -zcf - -C $filesystem . $lastcmd \ + TARCMD="ssh root@$computer \"nice -n 19 ionice -c3 tar --one-file-system --use-compress-program $compressor -cf - -C $filesystem . $lastcmd \ --exclude-from=$exf\" | pee \"cat > $TARFILE\" \"tar tzvf -\"" echo `date`" $computer: Running $TARCMD" >&2 eval $TARCMD > $DATE.idx @@ -156,6 +156,14 @@ backup() # We don't want to return 0 die fi + + # Check if pigz is available + if ssh -n root@$computer "pigz -V 2>/dev/null"; then + compressor=pigz + else + echo `date`" $computer: pigz missing; falling back to gzip." + compressor=gzip + fi filesystems="" -- 2.39.2