8

I made a backup of a database on my mac and tried to restore it on a computer with ubuntu. When I execute

psql -U uname -d dbname -f ~/dump_from_mac

I have a lot of error messages like "invalid command \N" and "relation 'SomeTable' does not exist". My question is very similar with Can't copy table to another database with pg_dump but I don't know how to fix my dump file. I wipe my mac and can't make new dump.

Community
  • 1
  • 1
Andrey
  • 190
  • 1
  • 1
  • 10

2 Answers2

8

My problem was solved by setting postgresql-contrib package

sudo apt-get install postgresql-contrib

and creating extension uuid-ossp in my db

CREATE EXTENSION "uuid-ossp";

My db haven't this extension by default and psql could not execute uuid_generate_v1() function from my dump file. In most cases install postgresql-contrib is enough, but sometimes problem may be in some missed extensions too.

Andrey
  • 190
  • 1
  • 1
  • 10
0

Here is my solution:

1) pg_dump with inserts:

pg_dump dbname --username=usernamehere --password --no-owner --no-privileges --data-only --inserts -t 'schema."Table"' > filename.sql

2) psql (restore your dumped file)

psql "dbname=dbnamehere options=--search_path=schemaname" --host hostnamehere --username=usernamehere -f filename.sql >& outputfile.txt

Note-1 ) Make sure that adding outputfile will increase speed of import.

Note-2 ) Do not forget to create table with exact same name and columns before importing with psql.

Ekrem Gurdal
  • 888
  • 10
  • 13