From 5158ffc00907e16ec86dc50e7ca9b88de84860c7 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 6 Aug 2014 13:29:59 +0200 Subject: backup.sh: comments; use sudo if necessary use sudo if necessary Signed-off-by: Florian Pritz --- backup.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'backup.sh') 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/ -- cgit v1.2.3-24-g4f1b