|
@@ -3,12 +3,16 @@ set -e
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
-source $DIR/restic-backup.env
|
|
|
+# First and only argument is the name of the backup configuration
|
|
|
+BACKUP_CFG_NAME=$1
|
|
|
|
|
|
-BASE_URL=https://dev.burdet.ch/git/jfburdet/backup-cfg/raw/master/restic
|
|
|
-INCLUDE_URL=$BASE_URL/$(hostname)/include.list
|
|
|
-EXCLUDE_URL1=$BASE_URL/$(hostname)/exclude.list
|
|
|
-EXCLUDE_URL2=$BASE_URL/exclude.list
|
|
|
+# This will set RESTIC_PASSWORD and RESTIC_REPOSITORY
|
|
|
+source $DIR/restic-backup-${BACKUP_CFG_NAME}.env
|
|
|
+
|
|
|
+BASE_URL=https://dev.burdet.ch/git/jfburdet/backup-cfg/raw/master/restic/${BACKUP_CFG_NAME}
|
|
|
+INCLUDE_URL=$BASE_URL/include.list
|
|
|
+EXCLUDE_URL1=$BASE_URL/exclude.list
|
|
|
+EXCLUDE_URL2=$BASE_URL/../exclude.list
|
|
|
|
|
|
include_file=$(mktemp)
|
|
|
exclude_file1=$(mktemp)
|
|
@@ -18,12 +22,12 @@ curl -f -s $INCLUDE_URL --output $include_file || (echo "Can't fetch include fil
|
|
|
curl -f -s $EXCLUDE_URL1 --output $exclude_file1 || (echo "Can't fetch exclude file $EXCLUDE_URL1" && exit 1)
|
|
|
curl -f -s $EXCLUDE_URL2 --output $exclude_file2 || (echo "Can't fetch exclude file $EXCLUDE_URL2" && exit 1)
|
|
|
|
|
|
+echo "Backing up :"
|
|
|
+cat $include_file
|
|
|
+# Lets make destination nice to display by removing tag string
|
|
|
|
|
|
-echo "Backing up $(cat $include_file) to $RESTIC_REPOSITORY"
|
|
|
-
|
|
|
-restic backup --files-from $include_file --exclude-file $exclude_file1 --exclude-file $exclude_file2 --exclude-caches
|
|
|
+restic backup --files-from $include_file --exclude-file $exclude_file1 --exclude-file $exclude_file2 --exclude-caches
|
|
|
|
|
|
rm -rf $include_file
|
|
|
rm -rf $exclude_file1
|
|
|
rm -rf $exclude_file2
|
|
|
-
|