38 lines
708 B
Bash
Executable file
38 lines
708 B
Bash
Executable file
#!/bin/bash
|
|
|
|
restoreDir=/etc/restore
|
|
pgsqlDir="$restoreDir/postgresql"
|
|
|
|
hook_before() {
|
|
if [[ -d "$pgsqlDir" ]]; then
|
|
rm -rf "$pgsqlDir" || exit 1
|
|
fi
|
|
|
|
state=$(nc 127.0.0.1 5400)
|
|
|
|
if [[ "$state" != "MASTER" ]]; then
|
|
#backupDate=$(date +"%Y-%m-%d")
|
|
|
|
mkdir -p "$pgsqlDir" || exit 2
|
|
/usr/local/sbin/pg_backup -c /etc/postgresql/9.6/main/pg_backup.config
|
|
fi
|
|
}
|
|
|
|
hook_after() {
|
|
rm -rf "$pgsqlDir" || 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
|