From: Steinar H. Gunderson Date: Mon, 6 Oct 2014 22:44:56 +0000 (+0200) Subject: Add an example script for the other side of non-privileged backup. X-Git-Url: https://git.sesse.net/?p=backup.sh;a=commitdiff_plain;h=4fff522ba73ee62bdd3e4434ea910d8ee6ce0229 Add an example script for the other side of non-privileged backup. --- diff --git a/output-encrypted-backup b/output-encrypted-backup new file mode 100644 index 0000000..2c8f835 --- /dev/null +++ b/output-encrypted-backup @@ -0,0 +1,36 @@ +#! /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 $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 $GPG_RECIPIENTS +fi +