resticprofiles-base/scripts/consul

40 lines
630 B
Bash
Executable file

#!/bin/bash
restoreDir=/etc/restore
consulDir="$restoreDir/consul"
check() {
if [[ -d "$consulDir" ]]; then
rm -rf "$consulDir" || exit 1
fi
}
hook_before() {
check
mkdir -p "$consulDir" || exit 1
pushd "$restoreDir" || exit 2
consul snapshot save "$consulDir/consul.snap"
popd || exit 2
}
hook_after() {
rm -rf "$consulDir" || exit 1
}
hook_fail() {
:
}
hook_final() {
:
}
case "$1" in
before) hook_before || exit $?;;
after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
esac