Skip to content
Snippets Groups Projects

[restore] indentations

Merged Jonathan Schaeffer requested to merge restore2 into master
1 file
+ 19
20
Compare changes
  • Side-by-side
  • Inline
@@ -32,35 +32,34 @@ function report_to_zabbix(){
}
function hook_script(){
psql --host $host -p 5432 -U $user -d $dbpreprod -f $1
if [[ $? -eq 0 ]]; then
report_to_zabbix "OK"
else
report_to_zabbix "Error on hook script $1"
fi
psql --host $host -p 5432 -U $user -d $dbpreprod -f $1
if [[ $? -eq 0 ]]; then
report_to_zabbix "OK"
else
report_to_zabbix "Error on hook script $1"
return 1
fi
}
function database_restore() {
# on récupere le dump qui a moins de 24 heures
# On récupere le dump qui a moins de 24 heures
DUMPFILE=$(find $DUMPDIR -name $1.dump -mtime -1| tail -1)
[[ -f $DUMPFILE ]] || {
echo $1.dump does not exist
report_to_zabbix "failed: $1.dump not found in $DUMPDIR"
return 1
}
echo pg_restore --no-owner --clean --no-password --host=$host -U postgres --dbname=$2 $DUMPFILE
pg_restore --no-owner --clean --no-password --host=$host -U postgres --dbname=$2 $DUMPFILE
report_to_zabbix "failed: $1.dump not found in $DUMPDIR"
return 1
}
echo pg_restore --no-owner --clean --no-password --host=localhost -U postgres --dbname=$2 $DUMPFILE
pg_restore --no-owner --clean --no-password --host=localhost -U postgres --dbname=$2 $DUMPFILE
code=$?
if [ $code -ne 0 ]; then
echo 1>&2 "Restore failed"
finlog=$(tail -1 $LOG)
report_to_zabbix "$finlog"
else
hook_script $LOCALDIR/../SQL/resifinv-views.sql
hook_script $LOCALDIR/../SQL/resifinv-views.sql
hook_script $LOCALDIR/../SQL/operator.sql
report_to_zabbix "Error restoring database: pg_restore --no-owner --clean --no-password --host=localhost -U postgres --dbname=$2 $DUMPFILE"
fi
hook_script $LOCALDIR/../SQL/resifinv-views.sql || exit 1
hook_script $LOCALDIR/../SQL/resifinv-foreign.sql || exit 1
hook_script $LOCALDIR/../SQL/operator.sql || exit 1
}
database_restore $dbprod $dbpreprod
report_to_zabbix "OK: $dbpreprod Restored"
Loading