Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Show the full, exact text of the error message(s). I also recommend using pg_dump -Fc and using pg_restore instead of psql. If you use psql at least use psql -v ON_ERROR_STOP=1 – Craig Ringer Mar 31 '14 at 12:08
up vote 2 down vote accepted

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.

share|improve this answer
Managed to find out what the error was with the -v and ON_ERROR_STOP=1 flags/parameters. I didn't install postgis on the 9.3 server. – wyred Apr 1 '14 at 3:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.