Postgres: Copy a database


November 17, 2012

Databases, Postgres

No Comment

For backup and development reasons a copy of a postgres database on the same system is often used. This is not a big problem and can be done directly as a SQL statement:

in your favorite console (psql, pgadmin, etc). There is one thing to remember, if you do a template copy this can not be done hot – so you need to assure that all users are logged of.
If you can not guarantee that, then you might better stick with doing a dump and then restoring it using pg_dump and psql:

Related Posts

Oracle: Timeout idle or dead sessions

Lately in a project we had a lot of problems with idle database sessions. It turns out that the DBA did not configure any timeout for the oracle database for idle or dead sessions. This is done with the PMON process, and via SQL*Net, by the sqlnet_expire_time parameter. SQL*Net In your sqlnet.ora file add the […]

Read More

Postgres: Remote copy a database between two machines using ssh

Sometimes it might be useful to copy a postgres database between two systems. This is not a big hazel and can be done with a simple one-liner (Port 22): [crayon-5cbd63aabeb86679387945/] and even if your ssh connection uses a different port (1234) you are good to go: [crayon-5cbd63aabeb8d708222646/]

Read More

Leave a Reply


  • An error has occurred, which probably means the feed is down. Try again later.