How do I make a duplicate copy of a postgresql database?

Some (I think) steps would be:

  • stop all queries
  • stop the postgresql daemon
  • copy the database files to a new location
  • make some changes to the configuration files
  • reload the server

Any ideas what should I change in the postgresql.conf in order to inform the postgresql server about the new database?

link|improve this question

78% accept rate
feedback

2 Answers

Copying files will not work.

Just pg_dump the database, and load it using pg_restore or psql (depending on options given to pg_dump).

link|improve this answer
How can I rename it? – Adam Matan Aug 30 '09 at 19:47
Rename what? You dump with pg_dump MYBASE > MYBASE.sql, you create the duplicate with createdb MYBASE2, you populate it with psql -f MYBASE.sql MYBASE2. – bortzmeyer Sep 3 '09 at 9:22
feedback

You have to correct all the absolute paths (if any) in the config files and the PGDATA variable (or option) in the startup script.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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