Thursday, May 5, 2022

[SOLVED] gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

Issue

I have a Bash script that creates a .tar.gz file, encrypts, and then sends it to a drive. However, I cannot open the .tar.gz file afterwards. Here is my process...

Bash script that encrypts.

#!/bin/sh

# Tar the automysqlbackup directory
tar -zcf "red-backup-$(date '+%Y-%m-%d').tar.gz" /var/lib/automysqlbackup/

# Encrypt the tar file
openssl aes-256-cbc -a -salt -in "red-backup-$(date '+%Y-%m-%d').tar.gz" -out "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -pass 'pass:MySecretPWD'

# Remove the original tar file
rm -rf "red-backup-$(date '+%Y-%m-%d').tar.gz"

# Upload to Google Drive
gdrive upload --file "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -p "jofhriout849uioejfoiu09"

Then I download the file and use

sudo openssl aes-256-cbc -e -in red-backup-2016-09-22.tar.gz.enc -out red-backup-2016-09-22.tar.gz

I then enter the passphrase for my file twice and I now get a file called

red-backup-2016-09-22.tar.gz

When I then try

sudo tar -zxvf red-backup-2016-09-22.tar.gz

I get

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I have also tried renaming the file .tar and also tried

sudo tar xvf red-backup-2016-09-22.tar.gz

and

sudo tar xvf red-backup-2016-09-22.tar

tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

Where am I going wrong?


Solution

This is probably because of your gzip version incompatibility.

Check these points first:

which gzip

/usr/bin/gzip or /bin/gzip

It should be either /bin/gzip or /usr/bin/gzip. If your gzip points to some other gzip application, please try by removing that path from your PATH environment variable.

Next is

gzip -V

gzip 1.3.5 (2002-09-30)

Your problem can be resolved with these check points.



Answered By - Roopendra
Answer Checked By - Gilberto Lyons (WPSolving Admin)