Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The input is a PostgreSQL custom-format dump. Use the pg_restore command-line client to restore this dump to a database.

I've encountered following error message when I'm trying to import postgres dump file to Google Cloud SQL.

The input is a PostgreSQL custom-format dump. Use the pg_restore command-line client to restore this dump to a database. This may take a few minutes. While this operation is running, you may continue to view information about the instance.

Please let me know how to import postgres dump file (which is hosted on Google Cloud Storage) to Google Cloud SQL?

like image 204
PPShein Avatar asked Dec 29 '17 06:12

PPShein


People also ask

How do I restore a PostgreSQL database?

To restore a PostgreSQL database, you can use the psql or pg_restore utilities. psql is used to restore text files created by pg_dump whereas pg_restore is used to restore a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats (custom, tar, or directory).


1 Answers

https://cloud.google.com/sql/docs/postgres/import-export/creating-sqldump-csv

Important: you must ensure that your SQL dump file is created with the following flags:

  • --no-owner Ownership change commands must not be included in the SQL dump file.
  • --format=plain Only plain SQL format is currently supported by Cloud SQL.

and from error you see I assume you used custom format, thus the import sql you prepared won't work (at least by documentation)

https://www.postgresql.org/docs/current/static/app-pgdump.html

--format=format Selects the format of the output. format can be one of the following:

p plain Output a plain-text SQL script file (the default).

c custom Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.

like image 52
Vao Tsun Avatar answered Oct 07 '22 08:10

Vao Tsun