#!/usr/bin/env bash # author: Daniel Sommer # license: MIT # exit on error # check permissions [[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1 # check if script exists script="$(dirname $(realpath "$0"))/$(hostname).sh" [[ ! -x "$script" ]] && printf "error: script '"$script"' does not exist or is not executable!\n" >&2 && exit 1 # get hostname host="$(hostname)" [[ -z "$host" ]] && host="$HOST" # setup restic export RESTIC_REPOSITORY="rest:http://192.168.100.101:8000" export RESTIC_PASSWORD="\$Velvet90" export RESTIC_COMPRESSION="max" export RESTIC_CACHE_DIR="/var/cache/restic" # setup log file log="/var/log/restic-"$(hostname)".log" # source / execute restic script source "$script" 2>&1 | tee "$log" # send a notification when finished /home/velvettear/.dots/scripts/notify.sh "backups" "$log" --title "$host" --icon "green_circle"