dot
dot

Reputation: 15660

postgresql dump - unable to use it to create a new database on a new server

I've run the following command on an existing database server:

 pg_dump -C -U testuser testdb -h 127.0.0.1 -F t> testdbdump

Now I'm trying to create this testdb on a new server. I tried to run the following command on the new server:

 pg_restore -h 127.0.0.1 testdbdump

I've created the testuser role on the new database server. And then I also tried the following:

pg_restore -i -h 127.0.0.1 -p 5432 -U postgres "testdbdump"

psql template1 postgres -f testdbdump

It did start to do some stuff, but I get a bunch of errors including:

psql:testdbdump:1720: invalid command \N
psql:testdbdump:1721: invalid command \N
psql:testdbdump:1808: ERROR:  syntax error at or near "user"
LINE 1: user=phone
        ^

Did I create the dump file incorrectly?

Upvotes: 0

Views: 171

Answers (1)

Peter Eisentraut
Peter Eisentraut

Reputation: 36729

Look up the --create option of pg_restore. It's made for this purpose.

Upvotes: 1

Related Questions