borgmatic-base/scripts/consul

32 lines
505 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
2021-09-05 01:23:02 -04:00
restoreDir=/etc/restore
consulDir="$restoreDir/consul"
hook_check() {
2021-09-05 01:23:02 -04:00
if [[ -d "$consulDir" ]]; then
rm -rf "$consulDir" || exit 1
fi
}
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
}
hook_post() {
2021-09-05 01:23:02 -04:00
rm -rf "$consulDir" || exit 1
}
case "$1" in
before_check) hook_check;;
before_backup) hook_pre;;
after_backup) hook_post;;
esac