PostgreSQL Migration – Upgrading from 9.2 to 9.3

migrationpostgresql-9.2postgresql-9.3

I have 2 CentOS servers, one is running PostgreSQL 9.2 and the other, 9.3.

I'm trying to migrate the database but I'm getting 'relation does not exist' errors.

What I did was on the 9.2 server:

pg_dump -h localhost -W -U postgres --clean DBName > dbname.dump

copied the dbname.dump file to the 9.3 server and then:

pgsql -h localhost -W -U postgres -f dbname.dump

Am I doing something wrong?

Other misc info, I am using the postgis extension and have some foreign key restraints.

Best Answer

I would do something like:

pg_dump -h localhost -W -U postgres --clean -f dbname.dump DBName

The move the file to the new server, create the new database with

createdb DBName

then restore with:

psql -d DBName -f dbname.dump -v ON_ERROR_STOP=1

Remember that if you have tablespaces created on the old DB you will have to manually recreate them in the new DB before importing the dump.