Re: Moving postgresql data to another computer

From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: dgcatanzaro(at)gmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Moving postgresql data to another computer
Date: 2010-05-11 20:44:32
Message-ID: AANLkTiknFNXkgjVz8GHXmO_kITt5M5Ily4qunyzLupzU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 11, 2010 at 1:16 PM, Donald Catanzaro, PhD
<dgcatanzaro(at)gmail(dot)com> wrote:

> I am a newbie to PostgreSQL and I recently installed it on my desktop
> (Windows XP) I created a database fine and worked a bunch of queries.  I am
> traveling now and I needed access to my database on my laptop (Windows
> Vista).  So before I left, I installed PosgreSQL on the laptop and then
> copied the data in the PostgreSQL data directory over to my laptop.
> I put the data directory from my desktop in a different place on my laptop
> and now I would like to access the data but I can not seem to figure out how
> to do this.

The easiest (and therefore safest) way to tranfer the databases from
one server cluster to another is to dump the entire contents of the
database to a text file and then load the text file onto the second
server instance.

This methods works as long as the second server instance postgresql
version >= to the initial instance. Its best if both versions are the
same if you want to transfer the data in both directions.

http://www.postgresql.org/docs/8.4/interactive/backup-dump.html
http://www.postgresql.org/docs/8.4/interactive/app-pg-dumpall.html
http://www.postgresql.org/docs/8.4/interactive/app-pgrestore.html

> I naively tried to just replace all the files in the data directory on my
> laptop with the files from the data directory of the desktop but when I do
> so, I get the following error:  "could not connect to server: Connection
> refused (0x0000274D/10061) Is the server running on host "127.0.0.1" and
> accepting TCP/IP connections on port 5432? "

Transferring the actual binary files is more risky since much more
care is needed to insure a consistent and functional copy.
Notice the method of creating a consistent copy:
http://www.postgresql.org/docs/8.4/interactive/backup-file.html

If you have a consistent copy, you might need to point PostgreSQL to
work from the copied data directory.
http://www.postgresql.org/docs/8.4/interactive/server-start.html

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Donald Catanzaro, PhD 2010-05-11 20:52:49 Re: Moving postgresql data to another computer
Previous Message Donald Catanzaro, PhD 2010-05-11 20:16:48 Moving postgresql data to another computer