123456789101112131415161718192021222324252627282930313233 |
- #!/bin/bash
- set -e
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- # First and only argument is the name of the backup configuration
- BACKUP_CFG_NAME=$1
- # 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)
- exclude_file2=$(mktemp)
- curl -f -s $INCLUDE_URL --output $include_file || (echo "Can't fetch include file $INCLUDE_URL" && exit 1)
- 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
- 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
|