Solved

Copy Postgres to another computer

Posted on 2009-05-15
3
1,029 Views
Last Modified: 2012-06-27
I just installed Postgres on a test server and I need some guidance on how to copy a Postgres database and all relevant information from a Windows server to my test Windows server

I know that I would need to do a dump from the source computer and restore it on the target computer, but I'm not sure of the exact commands or any other relevant information that I should also copy over such as the schema.  

Just as an FYI, I have the user name/password for the database root account and for the backup and restore.
0
Comment
Question by:abgtemp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
cminear earned 400 total points
ID: 24395698
Use 'pg_dump' to dump the database you want.  The simplest invocation would be:
  pg_dump -U <dbuser> --format p -f <outfile> <dbname>

Move the database file to the test system.  To recreate the database on your test system, I would do the following:
  dropdb -U <dbuser> <dbname>
  createdb -U <dbuser> <dbname>
  psql -U <dbuser> -d <dbname> -f <outfile>

Of course, this is probably fairly drastic, but it works just fine for me, when I want a copy of the production database in my test envionrment.  But there are options that can be used with 'pg_dump' to only get the data (or the schema) in the database dump.  In that case, you'd only need to TRUNCATE the database tables.

See http://www.postgresql.org/docs/8.3/interactive/app-pgdump.html for details.

(Note that I'm assuming the Windows version of these programs accept the same switch options as the Unix version.)
0
 

Author Comment

by:abgtemp
ID: 24396180
This sounds like it will work. I will leave this question open for one more day just in case I have anymore questions. I'm also bumping up the point to 400 for the quick response. Thanks!!!
0
 

Author Closing Comment

by:abgtemp
ID: 31581912
Quick and accurate answer!!! Thanks!!!!!!!!!!!!!!!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question