#!/bin/bash readonly toolName=duplicity readonly toolCronDir="/etc/cron.d" readonly toolPrefix="encBackup_" toolBin= toolSyslogTag= sq_aptOpt= sq_config=0 seq_config() { if initSeqConfig -p "${seq_fileName:?}" "${seq_configTemplate:?}" ; then sq_config=1 else dry || return 1 fi ## Apt cmdline option to suppress user interaction interactive || sq_aptOpt="-y" toolSyslogTag="${seq_fileName:?}-$seq_profileName" return 0 } step_1_info() { echo -n "Backup " if contextHelp ; then echo "selected profile" else echo "profile: $seq_profileName" fi echoinfo " [OPTIONS]" echoinfo " --no-purge, -n : Do not purge old backups after backup" echoinfo " --allow-source-mismatch, -a : see ${toolName:-} help" } step_1_options() { echo '[OPTIONS] [full|incremental]'; } step_1_alias() { echo "backup"; } step_1() { shift local arg local retVal local dupArgs local purgeAfter=1 local lSourceMismatch= for arg in "$@" ; do case "$1" in --no-purge|-n) purgeAfter=0 shift ;; --allow-source-mismatch|-a) dupArgs+=("--allow-source-mismatch") shift ;; esac done if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then echo " [I] Nothing to do. Check $seq_configFile" return 1 fi if [ -n "${1:-}" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then dupArgs+=("$1") elif [ -n "${1:-}" ] ; then echo " [W] $toolName command \"$1\" not recognized" return 1 fi echo " [I] Running backup profile [$seq_profileName]" if [ "${dupArgs[0]:-}" != "full" ] && [ -n "$EBU_MAX_FULLBKP_AGE" ] ; then dupArgs+=(--full-if-older-than "$EBU_MAX_FULLBKP_AGE") fi if [ -n "$EBU_VOLSIZE" ] ; then dupArgs+=(--volsize "$EBU_VOLSIZE") fi checkInstalled setPassphrase exe $toolBin "${dupArgs[@]:-}" "${EBU_SOURCE:?}" "${EBU_TARGET:?}" retVal=$? unsetPassphrase syslogEntry "Backup complete [$retVal]" if [ $purgeAfter -ne 0 ] ; then step purge fi } step_3_info() { echo "Verify selected backup"; } step_3_alias() { echo "verify"; } step_3() { shift if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then echo " [I] Nothing to do. Check $seq_configFile" return 1 fi checkInstalled setPassphrase exe $toolBin verify "$EBU_TARGET" "$EBU_SOURCE" unsetPassphrase } step_5_info() { echo "Restore files from backup" echoinfo " [OPTIONS]" echoinfo " --file-to-restore, -f : Relative path within backup" echoinfo " (file or folder)" echoinfo " --time, -t