]> git.sesse.net Git - backup.sh/commitdiff
Add an example script for the other side of non-privileged backup.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 6 Oct 2014 22:44:56 +0000 (00:44 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 6 Oct 2014 22:44:56 +0000 (00:44 +0200)
output-encrypted-backup [new file with mode: 0644]

diff --git a/output-encrypted-backup b/output-encrypted-backup
new file mode 100644 (file)
index 0000000..2c8f835
--- /dev/null
@@ -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
+