Restoring from Postgres sql file

2019-03-04 12:34发布

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?

1条回答
We Are One
2楼-- · 2019-03-04 12:44

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

查看更多
登录 后发表回答