1

I have a backup from PostgresSQL database created this way:

/usr/bin/pg_dump --no-owner --no-acl > dump.sql

When I try to restore on a different machine:

psql db < dump.sql it trows many errors: invalid command \N

When I try to use pg_restore:

pg_restore dump.sql -d db

Different error: pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

According to documentation this should be a non issue.

Any way to tell psql that \N character is a null value?

4
  • try psql -U role -d dbname -f filename.sql remove < Commented Nov 14, 2018 at 3:27
  • @dwir182 same error with invalid command \N Commented Nov 14, 2018 at 3:34
  • You backup use pg_dump seems weird.. There are no db you backup or even role To specify schema in db? Commented Nov 14, 2018 at 3:37
  • Please show us the first error message you get. Commented Nov 14, 2018 at 7:33

2 Answers 2

8

Oh hi me, it's me

Make sure:

  • Database exists
  • Importing user has permissions
  • Get the first error before \N ones flood in
  • psql -d database -f backup.sql -U user should do the trick for importing

Also eat healthy and get good rest. k bye

Sign up to request clarification or add additional context in comments.

Comments

2

this may be the case if the columns in the table and the columns in the file not match

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.