If it becomes necessary to recover the Postgres database from backups, the following should be useful.
The backups reside on the database server postgres.cs
in /backup/postgres
.
At present they are dumps produced by pg_dumpall
in the SQL command format. This means that each file is a huge psql
script containing all the commands required to restore a database cluster to the state it was in when the backup was taken.
Recovering can be done using the following steps:
postgres.cs
as postgres
, using the psql
command-line utility.
postgres
, template0
, and template1
). For example: drop database odyssey_dev;Note that this will require dropping all current sessions on those databases; when we did it, there were very few sessions so we just had to re-try dropping some of the databases a couple of times. In general, however, actually stopping the database is a better idea. Existing sessions can be found using the following command (as
postgres
): select * from pg_stat_activity;
\i /backup/postgres/apps-1247599621-alldb.sql
Doing the recovery this way should lead to output which can be described as follows:
setval
on each sequence to set its value to the appropriate next value.
-- IsaacMorland - 15 Jul 2009