]> git.sesse.net Git - backup.sh/blob - output-encrypted-backup
Support changing compressors (e.g. to get zstd or xz).
[backup.sh] / output-encrypted-backup
1 #! /bin/sh
2
3 set -e
4
5 # Script used for non-privileged backup; the backup user must have sudo
6 # for this.
7
8 ### Configuration -- change as needed.
9
10 #                  Steinar,  Trygve Tønnesland,  Skolmli
11 GPG_RECIPIENTS="-r 77978F76  -r 9AE75F05         -r 2DF56ABC"
12 EXCLUDEFROM=/home/samfundetbackup/.backup/exclude
13 ### end of config ###
14
15 PATH=
16 HOME=/root
17 FILESYSTEM="$1"
18 LASTDATE="$2"
19
20 # Don't allow people to give odd options
21 if echo "$FILESYSTEM" | /bin/grep -Eq ^-; then
22         echo Invalid filesystem. Exiting. 1>&2
23         exit 1
24 fi
25 if [ x"$FILESYSTEM" = x"" ]; then
26 echo Missing filesystem. Exiting. 1>&2
27         exit 1
28 fi
29
30 # Check if we have a valid date
31 if echo "$LASTDATE" | /bin/grep -Eq '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$'; then
32         /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
33 else    
34         /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
35 fi
36