summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backup.sh30
1 files changed, 18 insertions, 12 deletions
diff --git a/backup.sh b/backup.sh
index 66fc1fe..09f68b4 100644
--- a/backup.sh
+++ b/backup.sh
@@ -1,16 +1,22 @@
-#!/bin/sh
-
-# define a host "backup" in root's .ssh/config
-# create the globbing filters or remove the argument to backup()
+#!/bin/bash
+#
+# This is a simple backup script using duplicity. It's supposed to serve as a
+# starting point and to be adjusted to your system.
+#
+# Important steps:
+# - define a host "backup" in root's .ssh/config
+# - create the globbing filters or remove the argument to backup()
+# - read the script and adjust to your needs
if [[ $UID != 0 ]]; then
- echo "Error: need root" >&2
- exit 1
+ echo "Error: need root, restarting with sudo" >&2
+ exec sudo "$0" "$@"
fi
export HOME=/root
-# remove --no-encryption below if you set a passphrase
+# if you want to encrypt the backups remove --no-encryption in the duplicity call
+# and uncomment the lines that contain PASSPHRASE
#PASSPHRASE="randomstringhere"
backup() {
@@ -18,6 +24,7 @@ backup() {
dest=$2
shift 2
+ #export PASSPHRASE
duplicity \
--exclude-other-filesystems \
-v2 \
@@ -30,10 +37,9 @@ backup() {
"$@" "$src" "$dest"
duplicity --ssh-backend pexpect --force remove-older-than 120D "$dest"
+ #export PASSPHRASE=""
}
-#export PASSPHRASE
-backup / sftp://backup/backup/root/ --exclude-globbing-filelist /root/duplicity_root_filter
-backup /home/ sftp://backup/backup/home/ --exclude-globbing-filelist /root/duplicity_home_filter
-backup /boot/ sftp://backup/backup/boot/
-#export PASSPHRASE=""
+backup / sftp://backup/$HOSTNAME-backup/root/ --exclude-globbing-filelist /root/duplicity_root_filter
+backup /home/ sftp://backup/$HOSTNAME-backup/home/ --exclude-globbing-filelist /root/duplicity_home_filter
+backup /boot/ sftp://backup/$HOSTNAME-backup/boot/