#!/bin/bash ################################################################################ # Backup Preparations Script # -------------------------- # # This script should be run before performing a backup as it will do some # preparations. This script searches in all directories in # PRE_BACKUP_SCRIPT_DIRS for all executable scripts called # `pre_borg_backup.sh`. Every found script is executed and should do any # preparing action for a full system backup, such as dumping a database of a # docker container. # # Author: Robin Meier - robin@meier.si ################################################################################ # Load configuration script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) set -o allexport source ${script_dir}/config/backup > /dev/null 2>&1 set +o allexport # Import logging functionality logfile=${script_dir}/log/backup.log log_identifier="PREPAR" source ${script_dir}/functions/logging.sh # Exit if no backup script dirs are found if [[ -z "$PRE_BACKUP_SCRIPT_DIRS" ]]; then exit 0 fi highest_exit=0 log "Preparations Started" for directory in $PRE_BACKUP_SCRIPT_DIRS; do for script in $(find $directory -name pre_borg_backup.sh -executable); do log "$(date +%Y%m%d_%H%M%S) Running script $script" $script >> ${script_dir}/log/backup.log 2>&1 script_exit=$? highest_exit=$(( script_exit > highest_exit ? script_exit : highest_exit )) done done log "Preparations Finished" exit $highest_exit