#!/bin/bash toolName=duplicity toolBin= toolPpa="ppa:duplicity-team/duplicity-release-git" toolCronDir="/etc/cron.d" toolPrefix="encBackup_" toolSyslogTag= # Get script working directory # (when called from a different directory) WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd )" CONFIG=0 SCRIPT_NAME=$(basename -- $0) SCRIPT_NAME=${SCRIPT_NAME%%.*} CONFIG_FILE_TEMPLATE="$WDIR/${SCRIPT_NAME}.cfg.example" seq_config() { initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 else dry || return 1 fi toolSyslogTag="${SCRIPT_NAME}-$seq_profileName" } step_1_info() { echo -n "Backup " if contextHelp ; then echo -n "selected profile" else echo -n "profile: $seq_profileName" fi echo " [OPTIONS] [full|incremental]" echoinfo " [OPTIONS]" echoinfo " --no-purge, -n : Do not purge old backups after backup" } step_1_alias() { echo "backup"; } step_1() { shift local arg local retVal local dupArgs local purgeAfter=1 for arg in "$@" ; do case "$1" in --no-purge|-n) purgeAfter=0 shift ;; esac done if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then echo " [I] Nothing to do. Check $seq_configFile" return 1 fi if [ ! -z "$1" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then dupArgs+=("$1") elif [ ! -z "$1" ] ; then echo " [W] $toolName command \"$1\" not recognized" return 1 fi echo " [I] Running backup profile [$seq_profileName]" if [ "${dupArgs[0]}" != "full" ] && [ ! -z "$EBU_MAX_FULLBKP_AGE" ] ; then dupArgs+=(--full-if-older-than "$EBU_MAX_FULLBKP_AGE") fi if [ ! -z "$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 [OPTIONS] [TARGET]" echoinfo " [OPTIONS]" echoinfo " --file-to-restore, -f : Relative path within backup" echoinfo " (file or folder)" echoinfo " --time, -t