i=$(( $i + 1 ))
sleep 5
done
-if is_db_up ; then
+if ! is_db_up ; then
echo "...OK"
else
echo "... FAIL: database still up?"
if [ -f /root/dump ]
then
- echo "Restore database from dump file: psql -f- < /root/dump"
- su - postgres -c "psql -f-" < /root/dump > /var/log/pg_restore.log 2>/var/log/pg_restore.err
+ echo "Restore database from dump file: pg_restore -C /root/dump | psql -f- < "
+ pg_restore -C /root/dump | su - postgres -c "psql -f-" > /var/log/pg_restore.log 2>/var/log/pg_restore.err
else
# TODO: reinit the db from scratch and create the dump
echo "Couldn't restore the database: No /root/dump found"