#!/usr/bin/env bash # Copyright 2021 Adam Rabjerg # Licensed under GNU GPL-3.0-or-later # https://www.gnu.org/licenses/gpl-3.0.txt ## Source backup.env file for settings and secrets. ## it is possible to pass a filename as .env file. ## Passing a file makes it possible to have several .env files for different backups and one "work script". if [[ -z "$1" ]]; then source backup.env else source $1 fi ## Setup that everything is written to log exec > >(tee -ia ${LOGFILE} | tee -i ${LASTLOG}) exec 2>&1 ## Checks that a few important thins is set. ## In case a invalid path/file is passed. if [[ -z $REPOSITORY ]]; then echo "No \$REPOSITORY set, cannot make backup. \nDid you pass a valid .env file?" exit 4 fi if [[ -z $BACKUP_NAME ]]; then echo "No \$BACKUP_NAME set, cannot make backup. \nDid you pass valid .env file?" exit 5 fi echo "######## Backup started at $(date) ########" borg create -v --stats \ --exclude-from $BACKUP_EXCLUDE \ $REPOSITORY::$BACKUP_NAME \ $BACKUP_PATH echo "######### Backup Finished $(date) #########" /usr/bin/env python3 ./mail_template.py