?
Solved

Copy Postgres to another computer

Posted on 2009-05-15
3
Medium Priority
?
1,038 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 1600 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 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