Fixed config is being generated even though it should be skipped

This commit is contained in:
Enrico Ludwig 2024-05-24 12:44:52 +02:00
parent 792b0922dd
commit df7106a956

View File

@ -69,7 +69,7 @@ SKIP_CONFIG=0 # Set to 1 to skip the borgmatic configuration
readonly SCRIPT_NAME="Borgmatic Backup Setup Tool" readonly SCRIPT_NAME="Borgmatic Backup Setup Tool"
readonly SCRIPT_AUTHOR="Zion Networks at admin@zion-networks.de" readonly SCRIPT_AUTHOR="Zion Networks at admin@zion-networks.de"
readonly SCRIPT_SUPPORT="admin@zion-networks.de" readonly SCRIPT_SUPPORT="admin@zion-networks.de"
readonly VERSION="1.2.2" readonly VERSION="1.2.3"
# logging functions # logging functions
function inf { function inf {
@ -915,6 +915,8 @@ elif [ -f $BORGMATIC_CONFIG_FILE ] && [ $OVERRIDE_CONFIG -eq 1 ]; then
wrn "Existing borgmatic configuration file will be overridden!" wrn "Existing borgmatic configuration file will be overridden!"
fi fi
if [ $SKIP_CONFIG -eq 0 ]; then
cat > $BORGMATIC_CONFIG_FILE <<EOF cat > $BORGMATIC_CONFIG_FILE <<EOF
ssh_command: ssh -i $SSH_KEY_FILE -p $SSH_PORT ssh_command: ssh -i $SSH_KEY_FILE -p $SSH_PORT
@ -923,7 +925,7 @@ source_directories:
$(echo $BACKUP_DIRS | tr ' ' '\n' | sed -e 's/^/- /') $(echo $BACKUP_DIRS | tr ' ' '\n' | sed -e 's/^/- /')
repositories: repositories:
- path: ssh://$SSH_USER@$SSH_HOST:$SSH_PORT/$BACKUP_REPO - path: ssh://$SSH_USER@$SSH_HOST:$SSH_PORT/$BACKUP_REPO
label: $BACKUP_LABEL_PREFIX$(hostname | tr '[:lower:]' '[:upper:]') label: $BACKUP_LABEL_PREFIX$(hostname | tr '[:lower:]' '[:upper:]')
keep_daily: 7 keep_daily: 7
@ -932,18 +934,19 @@ keep_monthly: 12
keep_yearly: 1 keep_yearly: 1
checks: checks:
- name: repository - name: repository
- name: archives - name: archives
frequency: 4 weeks frequency: 4 weeks
EOF EOF
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
inf "Successfully created borgmatic configuration file." inf "Successfully created borgmatic configuration file."
else else
err "Failed to create borgmatic configuration file." err "Failed to create borgmatic configuration file."
err "If the error persists, please contact the support at $SCRIPT_SUPPORT." err "If the error persists, please contact the support at $SCRIPT_SUPPORT."
exit 1 exit 1
fi
fi fi
if ! inf_follow "Validating borgmatic configuration..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command /root/.local/pipx/venvs/borgmatic/bin/borgmatic config validate; then if ! inf_follow "Validating borgmatic configuration..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command /root/.local/pipx/venvs/borgmatic/bin/borgmatic config validate; then