gzip:stdin:不是gzip格式tar:孩子返回状态1 tar:错误不可恢复:现在退出

我有一个bash脚本,创build一个tar.gz并encryption然后发送到驱动器。 但是,我不能打开.tar.gz后。 这是我的过程

Bash脚本encryption。

#!/bin/sh # tar the automysqlbackup directory tar -zcf "red-backup-$(date '+%Y-%m-%d').tar.gz" /var/lib/automysqlbackup/ # encrypt the tar 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 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" 

然后我下载文件并使用

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

然后我input我的文件密码两次,现在我得到一个文件叫

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

当我然后尝试

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

并得到

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

我也尝试重命名文件.tar,并尝试

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

 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 

任何想法,我要出错?

这可能是因为你的gzip版本不兼容。

先检查以下几点:

哪个gzip

/ usr / bin / gzip或/ bin / gzip

它应该是/ bin / gzip或/ usr / bin / gzip。 如果您的gzip指向其他gzip应用程序,请尝试从PATH env变量中删除该路径。

接下来是

gzip -V

gzip 1.3.5(2002-09-30)

您的问题可以通过这些检查点来解决。

这意味着该文件并不是一个真正的gzipped tar文件 – 或者任何类型的gzip文件 – 尽管被命名为一个。

当你使用wget下载一个文件时,检查显示Length: unspecified [text/html]指示,它显示它是纯文本(text),它打算被解释为html。 检查下面的wget输出 –

 [root@XXXXX opt]# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz" --2017-10-12 12:39:40-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz Resolving download.oracle.com (download.oracle.com)... 23.72.136.27, 23.72.136.67 Connecting to download.oracle.com (download.oracle.com)|23.72.136.27|:80... connected. HTTP request sent, awaiting response... 302 Not Allowed Location: http://XXXX/FAQs/URLFiltering/ProxyWarning.html [following] --2017-10-12 12:39:40-- http://XXXX/FAQs/URLFiltering/ProxyWarning.html Resolving XXXX (XXXXX)... XXX.XX.XX.XXX Connecting to XXXX (XXXX)|XXX.XX.XX.XXX|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 17121 (17K) [text/html] Saving to: 'jdk-8u144-linux-x64.tar.gz' 100%[=========================================================================================================================================================================>] 17,121 --.-K/s in 0.05s 2017-10-12 12:39:40 (349 KB/s) - 'jdk-8u144-linux-x64.tar.gz' saved [17121/17121] 

这种证实你还没有收到一个gzip文件。

对于正确的文件, wget输出将显示如下所示的Length: 185515842 (177M) [application/x-gzip] ,如下所示 –

 [root@txcdtl01ss270n opt]# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz" --2017-10-12 12:50:06-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz Resolving download.oracle.com (download.oracle.com)... XX.XXX.XX.XX, XX.XX.XXX.XX Connecting to download.oracle.com (download.oracle.com)|XX.XX.XXX.XX|:80... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz [following] --2017-10-12 12:50:06-- https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz Resolving edelivery.oracle.com (edelivery.oracle.com)... XXX.XX.XXX.XX, 2600:1404:16:188::2d3e, 2600:1404:16:180::2d3e Connecting to edelivery.oracle.com (edelivery.oracle.com)|XXX.XX.XX.XXX|:443... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1507827127_f44251ebbb44c6e61e7f202677f94afd [following] --2017-10-12 12:50:07-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1507827127_f44251ebbb44c6e61 Connecting to download.oracle.com (download.oracle.com)|XX.XX.XXX.XX|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 185515842 (177M) [application/x-gzip] Saving to: 'jdk-8u144-linux-x64.tar.gz' 100%[=========================================================================================================================================================================>] 185,515,842 6.60MB/s in 28s 2017-10-12 12:50:34 (6.43 MB/s) - 'jdk-8u144-linux-x64.tar.gz' saved [185515842/185515842] 

以上显示了正确的gzip应用程序文件已被下载。

你也可以通过filehead fileview实用程序来检查文件。 例如,一个HTML文件会给出下面的输出 –

 [root@XXXXXX opt]# head jdk-8u144-linux-x64.tar.gz <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="/css/print.css" rel="stylesheet" media="print"> <link href="/css/main.css" rel="stylesheet" media="screen"> <link href="/css/font-awesome.min.css" rel="stylesheet"> 

上面显示的确实是一个HTML页面,我们正试图解压/解压 – 这是行不通的。 如果确实是一个正确的zip文件(本质上是二进制文件),那么head的输出会产生垃圾,

 [root@XXXX opt]# head jdk-8u144-linux-x64.tar.gz x rY [ms F      ڍtіl   DR   Ŋ  j $ $,`0 h _    /  = @Q w+  ձ* Hbfz { ~ { i x  k    ޾}    z   w    g     { ޼ ;{s    w   ⹳ 7 N    i       }  ¿g        ק   7  s     폺î߹     ~i  j /     ޿#   =  =>  ߿{}  |             3   X   ]9 ޠ    u     %ğ <^) H 8 F R t o L u  S% ds5 2_EZn t^    N3  (  <  |' q   R N gq Uv! ۻ p   rL  M  u  . Q 5 T  BNw !$  <> 7G'$ ,Mt4WY Gi" =  p ) VIN3    \ek  0  G  <L c ē t-   2   G:Ϣia  I <ʋg3   d H    [2` <I A 6 W  <  C       h  A0QL 2 4 -*  x   Е t%t1  f >+A͂ ,Lr   Fe:MBH  ɩ  C Q r S  <M b <,5   @   s  ݉c  sp f =g  ?  k   4 }  kh) ¹Z  #d *{   - .N ) e  s: H(VQ  3* $2󞖔  rϨv "o _  !A       B l=A |  @  0  1  5  4g       Se    H[2     t  5 Df    $1   b$  h Op    !Lvb!p  b 8^ Y   n  O  Ԫ߱  |  lW lu  * N M     / ^0~ ~ #  q        K  ; d   aw4    ݎ' ~ 7  ky o         t 'k  f    !vo   'o     . Pn\   +  K"FA{    n2    v  !/Ok  r4 c5 x$' . &w ! % ޠo      2   i  a0  Ag d    GH)G7~ g   b  % b  rt m~       t0   <            5 q t  K(  +Z<  =   :1 \ x p=t `  G@F   i     p8     H.   dMLE  e[ ` 'n  *h[  ; 0w'  6A ١M x fpeB>&   MO       ` @á/ "     (  ^   n  =    5  @ Mx  d:\YAn   ]| w>  S  FA9 J k! @   [root@XXXX opt]# head jdk-8u144-linux-x64.tar.gz x rY [ms F      ڍtіl   DR   Ŋ  j $ $,`0 h _    /  = @Q w+  ձ* Hbfz { ~ { i x  k    ޾}    z   w    g     { ޼ ;{s    w   ⹳ 7 N    i       }  ¿g        ק   7  s     폺î߹     ~i  j /     ޿#   =  =>  ߿{}  |             3   X   ]9 ޠ    u     %ğ <^) H 8 F R t o L u  S% ds5 2_EZn t^    N3  (  <  |' q   R N gq Uv! ۻ p   rL  M  u  . Q 5 T  BNw !$  <> 7G'$ ,Mt4WY Gi" =  p ) VIN3    \ek  0  G  <L c ē t-   2   G:Ϣia  I <ʋg3   d H    [2` <I A 6 W  <  C       h  A0QL 2 4 -*  x   Е t%t1  f >+A͂ ,Lr   Fe:MBH  ɩ  C Q r S  <M b <,5   @   s  ݉c  sp f =g  ?  k   4 }  kh) ¹Z  #d *{   - .N ) e  s: H(VQ  3* $2󞖔  rϨv "o _  !A       B l=A |  @  0  1  5  4g       Se    H[2     t  5 Df    $1   b$  h Op    !Lvb!p  b 8^ Y   n  O  Ԫ߱  |  lW lu  * N M     / ^0~ ~ #  q        K  ; d   aw4    ݎ' ~ 7  ky o         t 'k  f    !vo   'o     . Pn\   +  K"FA{    n2    v  !/Ok  r4 c5 x$' . &w ! % ޠo      2   i  a0  Ag d    GH)G7~ g   b  % b  rt m~       t0   <            5 q t  K(  +Z<  =   :1 \ x p=t `  G@F   i     p8     H.   dMLE  e[ ` 'n  *h[  ; 0w'  6A ١M x fpeB>&   MO       ` @á/ "     (  ^   n  =    5  @ Mx  d:\YAn   ]| w>  S  FA9 J k! @  

尝试从官方网站下载,并检查他们的下载链接是否已经改变。 同时检查你的代理设置,并确保你有正确的代理启用从正确的来源下载/ wget它。

希望这可以帮助。