Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This weekend I had to rebuild my laptop which had Postgres running. For some reason, I forgot to dump the data but I did make a complete copy of the original hard drive.

Is it possible to recover data from the original data files to transfer to another instance of Postgres?

share|improve this question

migrated from Apr 9 '13 at 3:01

This question came from our site for professional and enthusiast programmers.

Old and new PostgreSQL versions and host operating systems? – Craig Ringer Apr 9 '13 at 0:35
up vote 4 down vote accepted

Yes, it's fairly simple. You need to copy the database from the old disk image to a directory in the new host then start it using the same major version of PostgreSQL compiled with the same options (integer datetimes on/off, etc).

You can start the DB with a command like PGPORT=5433 pg_ctl -D /path/to/copy/of/old/database start. You must use the same PostgreSQL major version that the DB was created with before. If you're not sure what that was, check the PG_VERSION file in old data directory.

Once you've started a server with the old database you can then pg_dump the databases(s) and pg_dumpall --globals-only the users, etc, and load them into the new database.

Do not try to start the database directly on the old disk image, make a copy and start the copy.

You haven't provided details about versions, operating systems, how you installed Pg on the old and new machines, etc, so it's hard to provide more detail.

share|improve this answer
Craig, Thank you for your help. I will work on this later today. Thank you again. Ray – Ray Apr 9 '13 at 12:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.