Add pre-sync command

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-03-10 17:16:17 +01:00
parent 60e2c1979e
commit b9c28d5d11
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -14,6 +14,7 @@ set -euo pipefail
: ${PING_DOWN:=} # Send a ping (HTTP GET) to this URL when an exit-error ocurred : ${PING_DOWN:=} # Send a ping (HTTP GET) to this URL when an exit-error ocurred
: ${PING_MAX_TIME:=5} # Time in seconds to timeout the ping request : ${PING_MAX_TIME:=5} # Time in seconds to timeout the ping request
: ${PING_UP:=} # Send a ping (HTTP GET) to this URL when backup finished successfully : ${PING_UP:=} # Send a ping (HTTP GET) to this URL when backup finished successfully
: ${PRE_CMD:=} # Execute command before backing up (i.e. script to backup sqlite db)
: ${REMOTE_HOST:=} # Where to send the backups : ${REMOTE_HOST:=} # Where to send the backups
: ${SKIP_RESTORE_ON:=} # File to check, if exists restore will be skipped : ${SKIP_RESTORE_ON:=} # File to check, if exists restore will be skipped
: ${SSH_CONFIG_MOUNT:=~/.ssh-dist} # Where to search for ~/.ssh contents to copy into ~/.ssh (Secret mountPath) : ${SSH_CONFIG_MOUNT:=~/.ssh-dist} # Where to search for ~/.ssh contents to copy into ~/.ssh (Secret mountPath)
@ -150,6 +151,14 @@ function run_backup() {
info "Starting backup..." info "Starting backup..."
[[ -z $PRE_CMD ]] || {
info "Running pre-command '${PRE_CMD}'..."
${PRE_CMD} || {
error "Failed to run pre-command."
return 1
}
}
ensure_basedir || { ensure_basedir || {
error "Failed to ensure base-dir." error "Failed to ensure base-dir."
return 1 return 1