HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Copy PostgreSQL data from one PC to another

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqloneanotherfromdatacopy

Problem

I am migrating my server application from the existing system to another system. Unfortunately, the existing system is also the database server. It has data stored. Is it possible to copy this data to the other system? I have a copy of all the table schemas.

I have no idea on how to proceed. I am using PostgreSQL.

Solution

You could dump the database using pg_dump and then restore it on the new server using psql. Here's a couple of commands from the above link:

Create the backup:

pg_dump mydb > db.sql

Copy db.sql to the new server (specific command depends on OS)

Go to the new server

createdb mydb -E UTF8 (you don't have to specify UTF8 encoding, but I always do)

Then:

psql -d mydb -f db.sql

As I was answering, JohnP just answered with a fine answer but assumes that pg_hba.conf has been edited to allow remote connections and postgres.conf has been edited to listen on the network.

Context

StackExchange Database Administrators Q#23053, answer score: 16

Revisions (0)

No revisions yet.