Formatted all existing scripts with restic style

This commit is contained in:
Eric Renfro 2023-12-03 06:44:35 -05:00
parent c83ab1a749
commit a97d0551fa
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF
11 changed files with 156 additions and 47 deletions

View file

@ -4,14 +4,14 @@ restoreDir=/etc/restore
consulDir="$restoreDir/consul" consulDir="$restoreDir/consul"
hook_check() { check() {
if [[ -d "$consulDir" ]]; then if [[ -d "$consulDir" ]]; then
rm -rf "$consulDir" || exit 1 rm -rf "$consulDir" || exit 1
fi fi
} }
hook_pre() { hook_before() {
hook_check check
mkdir -p "$consulDir" || exit 1 mkdir -p "$consulDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -20,12 +20,21 @@ hook_pre() {
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
rm -rf "$consulDir" || exit 1 rm -rf "$consulDir" || exit 1
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_check) hook_check;; before) hook_before || exit $?;;
before_backup) hook_pre;; after) hook_after || exit $?;;
after_backup) hook_post;; fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="/etc/restore" restoreDir="/etc/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -25,11 +25,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
:
}
hook_fail() {
:
}
hook_final() {
: :
} }
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -3,7 +3,7 @@
restoreDir=/etc/restore restoreDir=/etc/restore
giteaDir="$restoreDir/gitea" giteaDir="$restoreDir/gitea"
hook_pre() { hook_before() {
if [[ -d "$giteaDir" ]]; then if [[ -d "$giteaDir" ]]; then
rm -rf "$giteaDir" || exit 1 rm -rf "$giteaDir" || exit 1
fi fi
@ -15,11 +15,22 @@ hook_pre() {
sudo -u git "${giteaHome}/bin/gitea" dump --type tar.xz --file - > "${giteaDir}/gitea-dump-${backupDate}.tar.xz" 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 rm -rf "$giteaDir" || exit 1
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -3,7 +3,7 @@
restoreDir=/etc/restore restoreDir=/etc/restore
ldapDir="$restoreDir/openldap" ldapDir="$restoreDir/openldap"
hook_pre() { hook_before() {
if [[ -d "$ldapDir" ]]; then if [[ -d "$ldapDir" ]]; then
rm -rf "$ldapDir" || exit 1 rm -rf "$ldapDir" || exit 1
fi fi
@ -54,11 +54,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
rm -rf "$ldapDir" || exit 1 rm -rf "$ldapDir" || exit 1
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="/etc/restore" restoreDir="/etc/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -23,11 +23,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
:
}
hook_fail() {
:
}
hook_final() {
: :
} }
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="/etc/restore" restoreDir="/etc/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -26,11 +26,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
:
}
hook_fail() {
:
}
hook_final() {
: :
} }
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="$HOME/.borgmatic/restore" restoreDir="$HOME/.borgmatic/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
brew bundle dump || exit 3 brew bundle dump || exit 3
@ -23,12 +23,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
: :
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_backup) hook_pre || exit $?;; before) hook_before || exit $?;;
after_backup) hook_post || exit $?;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="/etc/restore" restoreDir="/etc/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -11,11 +11,21 @@ hook_pre() {
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
:
}
hook_fail() {
:
}
hook_final() {
: :
} }
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -2,7 +2,7 @@
restoreDir="/etc/restore" restoreDir="/etc/restore"
hook_pre() { hook_before() {
mkdir -p "$restoreDir" || exit 1 mkdir -p "$restoreDir" || exit 1
pushd "$restoreDir" || exit 2 pushd "$restoreDir" || exit 2
@ -23,11 +23,21 @@ EOF
popd || exit 2 popd || exit 2
} }
hook_post() { hook_after() {
:
}
hook_fail() {
:
}
hook_final() {
: :
} }
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -3,7 +3,7 @@
restoreDir=/etc/restore restoreDir=/etc/restore
pgsqlDir="$restoreDir/postgresql" pgsqlDir="$restoreDir/postgresql"
hook_pre() { hook_before() {
if [[ -d "$pgsqlDir" ]]; then if [[ -d "$pgsqlDir" ]]; then
rm -rf "$pgsqlDir" || exit 1 rm -rf "$pgsqlDir" || exit 1
fi fi
@ -18,11 +18,21 @@ hook_pre() {
fi fi
} }
hook_post() { hook_after() {
rm -rf "$pgsqlDir" || exit 1 rm -rf "$pgsqlDir" || exit 1
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac

View file

@ -3,7 +3,7 @@
restoreDir=/etc/restore restoreDir=/etc/restore
vaultwardenDir="$restoreDir/vaultwarden" vaultwardenDir="$restoreDir/vaultwarden"
hook_pre() { hook_before() {
if [[ -d "$vaultwardenDir" ]]; then if [[ -d "$vaultwardenDir" ]]; then
rm -rf "$vaultwardenDir" || exit 1 rm -rf "$vaultwardenDir" || exit 1
fi fi
@ -16,11 +16,21 @@ hook_pre() {
sqlite3 "${vaultwardenHome}/data/db.sqlite3" ".backup '${vaultwardenDir}/db-${backupDate}.sqlite3'" sqlite3 "${vaultwardenHome}/data/db.sqlite3" ".backup '${vaultwardenDir}/db-${backupDate}.sqlite3'"
} }
hook_post() { hook_after() {
rm -rf "$vaultwardenDir" || exit 1 rm -rf "$vaultwardenDir" || exit 1
} }
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in case "$1" in
before_backup) hook_pre;; before) hook_before || exit $?;;
after_backup) hook_post;; after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac esac