.dots/scripts/restic/restic.sh
2024-08-28 15:47:52 +02:00

33 lines
913 B
Bash
Executable file

#!/usr/bin/env bash
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
# exit on error
set -e
# 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 "restic" "$log" --title "$host" --icon "green_circle"