# Common routines/settings for duplicacy shell scripts BASE_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" # https://forum.duplicacy.com/t/passwords-credentials-and-environment-variables/1094 SHARE=/share/CACHEDEV1_DATA STORAGE_URL=/share/TR-004/Duplicacy/storage STORAGE_NAME=default # Usage: log DUPLICACY-EXIT-STATUS MESSAGE # # References: # https://github.com/gilbertchen/duplicacy/wiki/Exit-Codes # log() { case $1 in 0 ) event=0 ;; # Information: backup was successful 1 ) event=1 ;; # Warning: command was interrupted 2 ) event=2 ;; # Error: command arguments are malformed 3 ) event=2 ;; # Error: invalid value for a command argument 100 ) event=2 ;; # Error: most run-time errors, including those from failed connections 101 ) event=2 ;; # Error: command encountered an error in a dependency library used by Duplicacy *) event=2 ;; # Error: other errors esac log_tool -t ${event} -a "[duplicacy backup] ${2}" -N duplicacy -G 'Job Status' } # Usage: run COMMAND # run() { echo ">>>>> $(date): ${1}" | tee -a "$LOG" eval ${1} >>"$LOG" 2>&1 status=$? if [ $status -ne 0 ] then msg=$(tail -n 1 "$LOG") echo "$status: $msg" log $status "${1}: $msg" exit 1 fi }