I\'m trying to restore my dump file, but it caused an error:
psql:psit.sql:27485: invalid command \\N
Is there a solution? I searched, but
I had the same problem, I created a new database and got invalid command \N
on restore with psql.
I solved it by setting the same tablespace with the old database.
For example, old database backup had tablespace "pg_default", I defined the same tablespace to the new database, and the above error has gone!
Most times, the solution is to install postgres-contrib
package.
I received the same error message when trying to restore from a binary pg_dump. I simply used pg_restore
to restore my dump and completely avoid the \N
errors, e.g.
pg_restore -c -F t -f your.backup.tar
Explanation of switches:
-f, --file=FILENAME output file name
-F, --format=c|d|t backup file format (should be automatic)
-c, --clean clean (drop) database objects before recreating
For me using postgreSQL 10 on SUSE 12, I resolved the invalid command \N
error by increasing disk space. Lack of disk space was causing the error for me. You can tell if you are out of disk space if you look at the file system your data is going to in the df -h
output. If file system/mount is at 100% used, after doing something like psql -f db.out postgres
(see https://www.postgresql.org/docs/current/static/app-pg-dumpall.html) you likely need to increase the disk space available.
I have run into this error in the past as well. Pavel is correct, it is usually a sign that something in the script created by pg_restore is failing. Because of all the "/N" errors, you aren't seeing the real problem at the very top of the output. I suggest:
pg_restore
--table=orders full_database.dump > orders.dump
) orders.dump
and delete a bunch of records)In my case, I didn't have the "hstore" extension installed yet, so the script was failing at the very top. I installed hstore on the destination database, and I was back in business.
My solution was this:
psql -U your_user your_db < your.file.here.sql 2>&1|more
this way I could read the error message
I hope this helps anybody.