diff --git a/scripts/consul b/scripts/consul index 99a24a9..3925e86 100755 --- a/scripts/consul +++ b/scripts/consul @@ -1,15 +1,27 @@ #!/bin/bash +restoreDir=/etc/restore +consulDir="$restoreDir/consul" + + hook_check() { - : + if [[ -d "$consulDir" ]]; then + rm -rf "$consulDir" || exit 1 + fi } hook_pre() { - consul snapshot save /etc/restore/consul.snap + hook_check + mkdir -p "$consulDir" || exit 1 + pushd "$restoreDir" || exit 2 + + consul snapshot save "$consulDir/consul.snap" + + popd || exit 2 } hook_post() { - : + rm -rf "$consulDir" || exit 1 } case "$1" in