1

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?

1 Answer 1

1

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).

8
  • Yes I mean an actual copy of the files. How do I stop and start the postmaster process? I am very new to PSQL
    – Deekor
    Commented Jul 2, 2013 at 17:05
  • Which operating system are you using and which version? Also, are you using a command line or a UI?
    – efesar
    Commented Jul 2, 2013 at 17:23
  • Mac OS. I use the psql shell
    – Deekor
    Commented Jul 2, 2013 at 17:46
  • Also where is the pg_data folder typically located?
    – Deekor
    Commented Jul 2, 2013 at 17:49
  • I would recommend using PGAdmin for doing backups and restores: pgadmin.org/download/macosx.php ... As for pg_data, it's in the root of your PostgreSQL installation folder. I don't know where it resides in OSX, but in many *NIX installations, it's in /var/pgsql/pg_data ...
    – efesar
    Commented Jul 2, 2013 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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