A lot of "invalid command \N" when I try to restore PostgreSQL dump
Asked Answered
M

1

9

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.

Mickens answered 3/8, 2015 at 17:36 Comment(2)
Use psql -v ON_ERROR_STOP=1 as suggested in: https://mcmap.net/q/117254/-psql-invalid-command-n-while-restore-sqlHalloran
Possible duplicate: #20428189Mcneil
M
10

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.

Mickens answered 3/8, 2015 at 20:30 Comment(4)
I had same problem. Since my backup had some extensions, solved installing postgresql-contribLebar
Just running apt-get install postgresql-contrib solved the problem for me after loading a database dumped with pg_dumpall -c -f out. Thanks!Barmen
This was very annoying. Thank you, kind soul.Measure
For all those working with containers like Docker, using apk --update add postgresql-contrib worked for me.Cale

© 2022 - 2024 — McMap. All rights reserved.