Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive
Solution 1
Per comments above, the solution was simple.
Extracting the dvdrental.zip file to an uncompressed .tar is not necessary as suggested in the tutorial instructions. pg_restore
will work if pointed to the directory where the database dump was extracted:
pg_restore -U <username> -d dvdrental <your/path/to/extracted/dir>/dvdrental
Solution 2
My problem was that when installing postgresql, I chose a different name for the superuser (root
for example, not postgres
). And the dvdrental/restore.sql
file uses the postgres
role.
So to solve this problem you need to create another superuser named postgres
.
createuser --superuser postgres
Then create server (PosgreSQL) with role postgres
and db dvdrental
with role postgres
.
After u can succesfuly restore db from extracted folder
Charlie Weems
Twilio Solutions Architect. Formerly worked at Code for America & TechChange.
Updated on September 25, 2021Comments
-
Charlie Weems over 2 years
I'm working through the Postgres DVD tutorial and am running into issues importing their sample database.
Running
pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gz
gives mepg_restore: [archiver] input file does not appear to be a valid archive
.My process so far has been the following:
- Download the dvdrental.zip file
- Extract it to a .tar using
tar czf dvd-database.tar.gz dvdrental.zip
(I've also tried extracting the zip to a folder first with the same result, as well as dropping the .gz) - Running
pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar
as stated above.
I'm currently using Postgres 9.5, which may be causing the issue. Looking for an answer that points out where I'm going wrong in this process or how to update an archive of a Postgres database to 9.5.