Forum OpenACS Q&A: Re: database recovery: how does postgres unix work?

Posted by Patrick Giagnocavo on
Eric, you are probably in good shape and will not lose any data.

The postgres data files can all be found under the postgres data directory.

Try running "pg_config --configure" (the old binary, assuming that it matches the MD5 checksums and is not therefore compromised); or if you have exactly the same setup on the new system, just look at where the data files are there. The data directory usually holds postgresql.conf and pg_hba.conf as well - so typing "locate pg_hba.conf" should work.

How to recover: assuming that both Postgres instances on the old and new drives are the same version and revision of the Postgres code:

make a backup of the old data directory, e.g. cp -R /old/data /root/pgbackup-data

su - postgresql (or whatever the postgres user is called on your system)

export PGDATA=/old/path/to/files
pg_ctl start (after a few lines you should see that Postgres is running)

then run psql -l to see if your databases are there.

At this point, the first thing to do is make a backup using pg_dump ; then, if that is successful, start up Postgres using the "new" file locations that reference the new drive and load your pg_dump backups.