3

Using below command to restore the database

Restoration command:

cat my_db_dump.sql.gz | gunzip | psql -d new_database -U my_username

Note: my_db_dump.sql.gz size is 4.5 GB, (extracted size will be around 70 GB)

Getting the below exception (after executing above restoration command)

gunzip: stdin: unexpected end of file
ERROR: unterminated quoted string at or near "'\x3c3f78
(hexadecimal junks removed)
LINE 1: SELECT pg_catalog.lowrite(0, '\x3c3f786d6c2076657273696f6e3d...

  • 1
    Not really proficient in Linux shell, but shouldn't that be gunzip -c my_db_dump.sql.gz | psql ...? – a_horse_with_no_name Jul 8 '15 at 9:33
  • same command (restoration command) was working fine earlier. so, I hope no issue with command syntax. db size might be an issue? or any corrupted format data in tuple? – Spike Jul 8 '15 at 9:42
  • you can also use zcat my_db_dump.sql.gz | psql -d new_database -U my_username – Craig Efrein Jul 8 '15 at 11:37
1

Based on the first error message, the .gz backup file seems to be truncated.

This could be confirmed with the command:

gunzip -c my_db_dump.sql.gz >/dev/null

Presumably this will lead to the same error message: unexpected end of file which is the root cause, the other error from postgres being the consequence of the abrupt end of the data stream.

If the .gz file is a copy resulting from a transfer, you want to compare its size against the size of the original, and transfer it again if it's incomplete. If that's the only copy or if the original itself is incomplete, completing the restore will not be possible.

  • Problem with the zipped file, found the issue. Thanks. – Spike Jul 27 '15 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.