7

So I want to decompress my something.gz file. Whenever I try to do this by using gunzip it ends after a little while saying there was an unexpected end of the file. The file itself is about 4gb.

Would appreciate any help regarding this problem.

Command: gunzip < db-20180518060048.sql.gz > db-20180518060048.sql

Response: gzip: stdin: unexpected end of file

Ends at: ('250

tukan
  • 17,050
  • 1
  • 20
  • 48
Daniel
  • 73
  • 1
  • 1
  • 7

2 Answers2

9

You have to use -d to decompress:

Your command would be:

gunzip -d db-20180518060048.sql.gz

Edit due to comment:

To test validity of your archive you can run

gunzip -t db-20180518060048.sql.gz

-t --test test compressed file integrity

The correct is only no output. Any other means that your archive is damaged.

tukan
  • 17,050
  • 1
  • 20
  • 48
  • Received the same response. – Daniel May 18 '18 at 10:37
  • @Daniel what filesystem do you have? You can also check integrity with `gunzip -t db-20180518060048.sql.gz` (if output is empty then the archive is valid) – tukan May 18 '18 at 10:39
  • Using the filesystem ext4 (Linux ubuntu 16) – Daniel May 18 '18 at 10:46
  • Ok, then you are safe. (ext4 supports up to 16TB). Is your archive valid? – tukan May 18 '18 at 10:55
  • Receiving same response: unexpected end of file. What does it imply to not be valid? – Daniel May 18 '18 at 10:56
  • @Daniel Then you archive is not valid. You need to get other copy of it. I'll edit the answer. – tukan May 18 '18 at 10:57
  • I went back and got another backup of the file. It seemed that something must have gone wrong during my previous backup because it works fine now:) Ty – Daniel May 18 '18 at 11:16
  • @Daniel great! I'm glad to hear that. Don't forget to vote: https://stackoverflow.com/help/someone-answers. Thank you – tukan May 18 '18 at 11:23
2

As your file is quite big, it might be worth writing it to standard output and piping it directly into the database. You can do this with the following command:

gzip -c db-20180518060048.sql.gz | mysql (args..)

This can be done with gunzip also, I just use gzip as a personal preference. Use man gzip to get more detail on this command.

David
  • 91
  • 1
  • 4