Save the psql database state as per stackoverflow.com/questions/37984733/postgresql-database-export-to-sql-file with our web/bin/pg_dump helper:
Then to restore it later with web/bin/pg_restore:
stackoverflow.com/questions/2732474/restore-a-postgres-backup-file-using-the-command-line
web/bin/pg_dump -Fc -f tmp.dump
web/bin/pg_restore tmp.dump