]> code.delx.au - monosys/commitdiff
Added ssh backup scripts
authorJames Bunton <jamesbunton@fastmail.fm>
Tue, 27 Jul 2010 10:05:26 +0000 (20:05 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Tue, 27 Jul 2010 10:05:26 +0000 (20:05 +1000)
scripts/backup-generic [new file with mode: 0644]
scripts/rsync-ssh-backup [new file with mode: 0755]

diff --git a/scripts/backup-generic b/scripts/backup-generic
new file mode 100644 (file)
index 0000000..f7c5362
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash -e
+
+# Run this at a lower priority to avoid disrupting the rest of the system
+# Exclude other filesystems from the backup. This leaves only the files we
+# want, on the root file system, to back up.
+# Also exclude other large collections of files which we don't care to save.
+
+if [ -f /.backup_running ]; then
+    echo "Backup already running!"
+    exit 1
+fi
+
+touch /.backup_running
+
+ionice -c3 nice -n5 \
+    rdiff-backup \
+        --exclude-other-filesystems \
+        --exclude-sockets \
+        --exclude '/backup' \
+        --exclude '/tmp' \
+        --exclude '/var/cache/apt/archives' \
+        --exclude '/var/log' \
+        / /backup/
+# Remove old backups
+sleep 3600
+ionice -c3 nice -n5 rdiff-backup -v1 --remove-older-than 60D /backup/
+
+rm -f /.backup_running
+
+exit 0
+
diff --git a/scripts/rsync-ssh-backup b/scripts/rsync-ssh-backup
new file mode 100755 (executable)
index 0000000..fc5e7b1
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+case "$SSH_ORIGINAL_COMMAND" in
+*\&*)
+echo "Rejected" >&2
+;;
+*\(*)
+echo "Rejected" >&2
+;;
+*\{*)
+echo "Rejected" >&2
+;;
+*\;*)
+echo "Rejected" >&2
+;;
+*\<*)
+echo "Rejected" >&2
+;;
+*\`*)
+echo "Rejected" >&2
+;;
+*\|*)
+echo "Rejected" >&2
+;;
+rsync\ --server*)
+ionice -c3 nice -n5 $SSH_ORIGINAL_COMMAND
+;;
+*)
+echo "Rejected" >&2
+;;
+esac
+