Skip site navigation (1) Skip section navigation (2)

Re: Copy database to another machine

From: Thom Brown <thom(at)linux(dot)com>
To: Nuno Ferreira <nunoadferreira(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Copy database to another machine
Date: 2011-10-26 16:46:06
Message-ID: CAA-aLv4yDS4=PVAmx2XDJ1_B8yyVbrojb2J33ftHxoxdZ+=yVw@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
On 26 October 2011 14:38, Nuno Ferreira <nunoadferreira(at)gmail(dot)com> wrote:
> Good afternoon,
> I'm trying to copy one database from one machine to another. How can I do
> it?
> Can I just simply copy and paste the files? I need to close the database
> first or I can copy the files with it open?

No, you can't copy and paste the files, but you can do it in one step:

pg_dump -t table_to_dump source_database_name | psql destination_database_name

Assuming the table does't already exist in the destination, it will
create and populate the table in the destination database.
-- 
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

pgsql-novice by date

Next:From: jjurbanDate: 2011-10-26 16:54:56
Subject: Re: Copy database to another machine
Previous:From: Andreas KretschmerDate: 2011-10-26 16:42:03
Subject: Re: Copy database to another machine

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group