#! /bin/bash until psql $DATABASE_URL < /dev/null; do sleep 1 done for f in /mnt/save/$(ls /mnt/save | sort -r); do echo restore $f psql $DATABASE_URL < $f &> /dev/null ret=$? echo restore result: $ret # TODO server isn't started to assert db is OK exit $ret if [ $ret == 0 ]; then if curl -sS -i localhost:80 | grep login; then exit $ret fi fi done