title: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
body: <p>I have a Bash script that creates a <em>.tar.gz</em> file, encrypts, and then sends it to a drive. However, I cannot open the <em>.tar.gz</em> file afterwards. Here is my process...</p>
  <p>Bash script that encrypts.</p>
  <pre class="lang-none prettyprint-override"><code>#!/bin/sh
  
  # Tar the automysqlbackup directory
  tar -zcf &quot;red-backup-$(date '+%Y-%m-%d').tar.gz&quot; /var/lib/automysqlbackup/
  
  # Encrypt the tar file
  openssl aes-256-cbc -a -salt -in &quot;red-backup-$(date '+%Y-%m-%d').tar.gz&quot; -out &quot;red-backup-$(date '+%Y-%m-%d').tar.gz.enc&quot; -pass 'pass:MySecretPWD'
  
  # Remove the original tar file
  rm -rf &quot;red-backup-$(date '+%Y-%m-%d').tar.gz&quot;
  
  # Upload to Google Drive
  gdrive upload --file &quot;red-backup-$(date '+%Y-%m-%d').tar.gz.enc&quot; -p &quot;jofhriout849uioejfoiu09&quot;
  </code></pre>
  <p>Then I download the file and use</p>
  <pre class="lang-none prettyprint-override"><code>sudo openssl aes-256-cbc -e -in red-backup-2016-09-22.tar.gz.enc -out red-backup-2016-09-22.tar.gz
  </code></pre>
  <p>I then enter the passphrase for my file twice and I now get a file called</p>
  <pre class="lang-none prettyprint-override"><code>red-backup-2016-09-22.tar.gz
  </code></pre>
  <p>When I then try</p>
  <pre class="lang-none prettyprint-override"><code>sudo tar -zxvf red-backup-2016-09-22.tar.gz
  </code></pre>
  <p>I get</p>
  <pre class="lang-none prettyprint-override"><code>gzip: stdin: not in gzip format
  tar: Child returned status 1
  tar: Error is not recoverable: exiting now
  </code></pre>
  <p>I have also tried renaming the file .tar and also tried</p>
  <pre class="lang-none prettyprint-override"><code>sudo tar xvf red-backup-2016-09-22.tar.gz
  </code></pre>
  <p>and</p>
  <pre class="lang-none prettyprint-override"><code>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
  </code></pre>
  <p>Where am I going wrong?</p>