summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-08-06 13:29:59 +0200
committerFlorian Pritz <bluewind@xinu.at>2014-08-06 13:29:59 +0200
commit5158ffc00907e16ec86dc50e7ca9b88de84860c7 (patch)
tree861960e53b69a0f1004e9d94392189cf9c70024f
parent280294bb1690a98349f17a2798aee0ef06abbcce (diff)
downloadbin-5158ffc00907e16ec86dc50e7ca9b88de84860c7.tar.gz
bin-5158ffc00907e16ec86dc50e7ca9b88de84860c7.tar.xz
backup.sh: comments; use sudo if necessary use sudo if necessary
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-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/