2021-09-03 15:11:32 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-09-05 01:23:02 -04:00
|
|
|
restoreDir=/etc/restore
|
|
|
|
consulDir="$restoreDir/consul"
|
|
|
|
|
|
|
|
|
2021-09-03 15:11:32 -04:00
|
|
|
hook_check() {
|
2021-09-05 01:23:02 -04:00
|
|
|
if [[ -d "$consulDir" ]]; then
|
|
|
|
rm -rf "$consulDir" || exit 1
|
|
|
|
fi
|
2021-09-03 15:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
hook_pre() {
|
2021-09-05 01:23:02 -04:00
|
|
|
hook_check
|
|
|
|
mkdir -p "$consulDir" || exit 1
|
|
|
|
pushd "$restoreDir" || exit 2
|
|
|
|
|
|
|
|
consul snapshot save "$consulDir/consul.snap"
|
|
|
|
|
|
|
|
popd || exit 2
|
2021-09-03 15:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
hook_post() {
|
2021-09-05 01:23:02 -04:00
|
|
|
rm -rf "$consulDir" || exit 1
|
2021-09-03 15:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
before_check) hook_check;;
|
|
|
|
before_backup) hook_pre;;
|
|
|
|
after_backup) hook_post;;
|
|
|
|
esac
|