#!/usr/bin/env bash # DRY="-n " DRY= CONFIG_ROOT="$HOME/.config/restic" usage() { echo "$0 " echo echo "Known profiles:" echo ls -1 $CONFIG_ROOT exit 1 } if [ ! -d $CONFIG_ROOT ] ; then echo "$CONFIG_ROOT hasn't been created; you need to create a profile for the backup you want to run." exit 1 fi if [ $# -lt 1 ] ; then usage fi PROFILE=$1 shift PROFILE_ROOT=$CONFIG_ROOT/$PROFILE if [ ! -d "$PROFILE_ROOT" ] ; then echo "Profile '$PROFILE' not found in $CONFIG_ROOT" exit 2 fi export RESTIC_PASSWORD_COMMAND="pass restic/$PROFILE/$HOSTNAME" CMDLINE="restic backup --one-file-system --exclude-caches $DRY" EXCLUDE_FILE=$PROFILE_ROOT/excludes.txt if [ -r $EXCLUDE_FILE ] ; then CMDLINE="$CMDLINE --exclude-file $EXCLUDE_FILE" fi REPO=$PROFILE_ROOT/repo.txt SOURCES=$PROFILE_ROOT/sources.txt CMDLINE="$CMDLINE -r $(cat $REPO) $(cat $SOURCES) $@" # echo "Backup:" # echo -e "\tPassword command: $RESTIC_PASSWORD_COMMAND" # echo -e "\tCommand: $CMDLINE" $CMDLINE