Get old database off external hard drive

Posted on

Question :

My hard drive crashed yesterday, luckily I had a back up. I didn’t restore from backup though cause I needed a fresh system anyways. However there was a development database I would like back.

Is there a way to grab an old database file from my back up and somehow get that database onto my new localhost?

Answer :

When you say back up, do you mean a formatted back up as in the kind produced by pg_dump or an actual copy of the files in the pg_data folder?

If pg_dump, then you can restore using pg_restore or the in the UI using PGAdmin.

If pg_data folder, then you can install a new instance of Postgres and drop the pg_data folder from the old version in the same place where the new version is (but first stop the postmaster process and rename the new version of pg_data to pg_data_old first). As long as the major version numbers are the same, when you restart the postmaster process, it will read the data and log files and config files just fine (unless you have some special circumstances that I don’t know about).

Leave a Reply

Your email address will not be published. Required fields are marked *