2

I am trying to open a SQL Script of PostgreSQL (.sql file) that contains the Create Database and INSERT statements but when I try to restore the database using PgAdmin 4 it gives me error stating "pg_restore: [archiver] input file does not appear to be a valid archive" . I selected the following fields in the Restore Database dialog box:

Format - as Custom or tar

Filename - C:\Users\parwa\Desktop\DWBI\Assignment - 2(Chinook SQL - 2)\Question Content\Chinook_PostgreSql.sql

Number of Jobs - (left this field blank)

Role name - Postgres

I am not sure why it's giving me this error. Any help regarding this will be greatly appreciated. Thanks!

spideypack
  • 113
  • 1
  • 2
  • 9
  • Possible duplicate of [Export and import table dump (.sql) using pgAdmin](https://stackoverflow.com/questions/18736345/export-and-import-table-dump-sql-using-pgadmin) – e4c5 Jun 04 '17 at 11:38
  • Why did you select "**Custom or tar**" if the file clearly is a SQL script? Just run the script –  Jun 04 '17 at 12:31

1 Answers1

3

In pgAdmin 4 the Restore Dialog is a UI interface to the pg_restore command line utility (https://www.postgresql.org/docs/9.2/static/app-pgrestore.html), I don't think it deals with sql files directly.

The documentation says

You can use the Query Tool to play back the script created during a plain-text backup made with the Backup dialog. For more information about backing up or restoring, please refer to the documentation for pg_dump or pg_restore.

Which indicates that to restore the sql file you have you need to use the Query Tool instead.

Tools -> Query Tool and you can open or paste the file in there and run it.

Neil Anderson
  • 1,265
  • 12
  • 19