diff --git a/scripts/consul b/scripts/consul index 3925e86..c725234 100755 --- a/scripts/consul +++ b/scripts/consul @@ -4,14 +4,14 @@ restoreDir=/etc/restore consulDir="$restoreDir/consul" -hook_check() { +check() { if [[ -d "$consulDir" ]]; then rm -rf "$consulDir" || exit 1 fi } -hook_pre() { - hook_check +hook_before() { + check mkdir -p "$consulDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -20,12 +20,21 @@ hook_pre() { popd || exit 2 } -hook_post() { +hook_after() { rm -rf "$consulDir" || exit 1 } +hook_fail() { + : +} + +hook_final() { + : +} + case "$1" in - before_check) hook_check;; - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/flatpak b/scripts/flatpak index fa1e428..89564f9 100755 --- a/scripts/flatpak +++ b/scripts/flatpak @@ -2,7 +2,7 @@ restoreDir="/etc/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -25,11 +25,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { + : +} + +hook_fail() { + : +} + +hook_final() { : } case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/gitea b/scripts/gitea index 8e40bbd..8570c9c 100755 --- a/scripts/gitea +++ b/scripts/gitea @@ -3,7 +3,7 @@ restoreDir=/etc/restore giteaDir="$restoreDir/gitea" -hook_pre() { +hook_before() { if [[ -d "$giteaDir" ]]; then rm -rf "$giteaDir" || exit 1 fi @@ -15,11 +15,22 @@ hook_pre() { sudo -u git "${giteaHome}/bin/gitea" dump --type tar.xz --file - > "${giteaDir}/gitea-dump-${backupDate}.tar.xz" } -hook_post() { +hook_after() { rm -rf "$giteaDir" || exit 1 } +hook_fail() { + : +} + +hook_final() { + : +} + + case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/openldap b/scripts/openldap index bf3032e..a1618c5 100755 --- a/scripts/openldap +++ b/scripts/openldap @@ -3,7 +3,7 @@ restoreDir=/etc/restore ldapDir="$restoreDir/openldap" -hook_pre() { +hook_before() { if [[ -d "$ldapDir" ]]; then rm -rf "$ldapDir" || exit 1 fi @@ -54,11 +54,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { rm -rf "$ldapDir" || exit 1 } +hook_fail() { + : +} + +hook_final() { + : +} + case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/os_fedora b/scripts/os_fedora index 7b0f1ff..a815278 100755 --- a/scripts/os_fedora +++ b/scripts/os_fedora @@ -2,7 +2,7 @@ restoreDir="/etc/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -23,11 +23,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { + : +} + +hook_fail() { + : +} + +hook_final() { : } case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/os_garuda b/scripts/os_garuda index 15b842c..5fd8b54 100755 --- a/scripts/os_garuda +++ b/scripts/os_garuda @@ -2,7 +2,7 @@ restoreDir="/etc/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -26,11 +26,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { + : +} + +hook_fail() { + : +} + +hook_final() { : } case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/os_macos b/scripts/os_macos index 0945931..37d637a 100755 --- a/scripts/os_macos +++ b/scripts/os_macos @@ -2,7 +2,7 @@ restoreDir="$HOME/.borgmatic/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 brew bundle dump || exit 3 @@ -23,12 +23,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { : } +hook_fail() { + : +} + +hook_final() { + : +} case "$1" in - before_backup) hook_pre || exit $?;; - after_backup) hook_post || exit $?;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/os_solus b/scripts/os_solus index e20602c..65e5bcc 100755 --- a/scripts/os_solus +++ b/scripts/os_solus @@ -2,7 +2,7 @@ restoreDir="/etc/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -11,11 +11,21 @@ hook_pre() { popd || exit 2 } -hook_post() { +hook_after() { + : +} + +hook_fail() { + : +} + +hook_final() { : } case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/os_suse b/scripts/os_suse index 4de7eb7..b11bef8 100755 --- a/scripts/os_suse +++ b/scripts/os_suse @@ -2,7 +2,7 @@ restoreDir="/etc/restore" -hook_pre() { +hook_before() { mkdir -p "$restoreDir" || exit 1 pushd "$restoreDir" || exit 2 @@ -23,11 +23,21 @@ EOF popd || exit 2 } -hook_post() { +hook_after() { + : +} + +hook_fail() { + : +} + +hook_final() { : } case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/postgresql b/scripts/postgresql index 1e84fc7..79f9cae 100755 --- a/scripts/postgresql +++ b/scripts/postgresql @@ -3,7 +3,7 @@ restoreDir=/etc/restore pgsqlDir="$restoreDir/postgresql" -hook_pre() { +hook_before() { if [[ -d "$pgsqlDir" ]]; then rm -rf "$pgsqlDir" || exit 1 fi @@ -18,11 +18,21 @@ hook_pre() { fi } -hook_post() { +hook_after() { rm -rf "$pgsqlDir" || exit 1 } +hook_fail() { + : +} + +hook_final() { + : +} + case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac diff --git a/scripts/vaultwarden b/scripts/vaultwarden index 5bd3231..5986c56 100755 --- a/scripts/vaultwarden +++ b/scripts/vaultwarden @@ -3,7 +3,7 @@ restoreDir=/etc/restore vaultwardenDir="$restoreDir/vaultwarden" -hook_pre() { +hook_before() { if [[ -d "$vaultwardenDir" ]]; then rm -rf "$vaultwardenDir" || exit 1 fi @@ -16,11 +16,21 @@ hook_pre() { sqlite3 "${vaultwardenHome}/data/db.sqlite3" ".backup '${vaultwardenDir}/db-${backupDate}.sqlite3'" } -hook_post() { +hook_after() { rm -rf "$vaultwardenDir" || exit 1 } +hook_fail() { + : +} + +hook_final() { + : +} + case "$1" in - before_backup) hook_pre;; - after_backup) hook_post;; + before) hook_before || exit $?;; + after) hook_after || exit $?;; + fail) hook_fail || exit $?;; + finally) hook_final || exit $?;; esac