#! /bin/sh set -e # Script used for non-privileged backup; the backup user must have sudo # for this. ### Configuration -- change as needed. # Steinar, Trygve Tønnesland, Skolmli GPG_RECIPIENTS="-r 77978F76 -r 9AE75F05 -r 2DF56ABC" EXCLUDEFROM=/home/samfundetbackup/.backup/exclude ### end of config ### PATH= HOME=/root FILESYSTEM="$1" LASTDATE="$2" # Don't allow people to give odd options if echo "$FILESYSTEM" | /bin/grep -Eq ^-; then echo Invalid filesystem. Exiting. 1>&2 exit 1 fi if [ x"$FILESYSTEM" = x"" ]; then echo Missing filesystem. Exiting. 1>&2 exit 1 fi # Check if we have a valid date if echo "$LASTDATE" | /bin/grep -Eq '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$'; then /usr/bin/nice -n 19 /usr/bin/ionice -c3 /bin/tar --ignore-failed-read --warning=no-file-changed --warning=no-file-ignored --one-file-system -c -C "$FILESYSTEM" --newer="$LASTDATE" --exclude-from="$EXCLUDEFROM" . | /usr/bin/pigz | /usr/bin/gpg --sign --encrypt --cipher-algo aes --compress-algo none $GPG_RECIPIENTS else /usr/bin/nice -n 19 /usr/bin/ionice -c3 /bin/tar --ignore-failed-read --warning=no-file-changed --warning=no-file-ignored --one-file-system -c -C "$FILESYSTEM" --exclude-from="$EXCLUDEFROM" . | /usr/bin/pigz | /usr/bin/gpg --sign --encrypt --cipher-algo aes --compress-algo none $GPG_RECIPIENTS fi