resticprofiles-base/scripts/consul

41 lines
630 B
Text
Raw Normal View History

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