copy a postgres dbase to the same machine with different name?

Started by Jonathan Robyover 20 years ago2 messagesgeneral
Jump to latest
#1Jonathan Roby
robyj@cc.umanitoba.ca

Hi everyone,

For a project here at work I look after a web app that communicates with a postgresql database. We need to clone/copy the existing database to run app upgrades on the clone database and then use the upgraded database in place of the original.

I've read the pg_dump/pg_restore man pages, tried to google for a technique, but haven't found anything that adequate explains it & i'd rather not screw up a live database <grin>

Thanks for any help,
Jon.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jonathan Roby (#1)
Re: copy a postgres dbase to the same machine with different name?

"Jonathan Roby" <robyj@cc.umanitoba.ca> writes:

For a project here at work I look after a web app that communicates with =
a postgresql database. We need to clone/copy the existing database to =
run app upgrades on the clone database and then use the upgraded =
database in place of the original.

Are you talking about cloning the whole installation to run under a
separate postmaster? Or are you trying to create a new database with
a different name under the same postmaster?

If the latter, and you can idle the database while copying it, the
TEMPLATE option to CREATE DATABASE will serve.

regards, tom lane