LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   silly bash question (https://www.linuxquestions.org/questions/programming-9/silly-bash-question-428364/)

bennethos 03-25-2006 09:31 AM

silly bash question
 
Hi,

i use fetchmail to pop my mail and would have liked to archive it each month

so i added a cron that runs each 1st of the month to backup that large mail file.

the bash script looks like this :
----------
mariko:~# cat mail_archive.sh
#!/bin/bash

date=`date +_%d_%m_%Y`
#echo $date
tar cvf /home/benjamin/mail_backup/mail"$date".tar.gz /var/mail/benjamin
-----------

the file /var/mail/benjamin is my fetchmail file that contains all the mail.

when i check the dir /home/benjamin/mail_backup/ it contains a neat file with the date an all.

problem is i cant untar it

if i execute tar zxf mail_18_02_2006.tar.gz it says :

mariko:/home/benjamin/mail_backup# tar zxf mail_18_02_2006.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors

Hope you guys can help me out :)

thx in advance

jomen 03-25-2006 09:46 AM

You created a tar archive - with no compression!
to create a gzipped tar archive - add the -z switch to your script

Code:

#!/bin/bash

date=`date +_%d_%m_%Y`
#echo $date
tar cvfz /home/benjamin/mail_backup/mail"$date".tar.gz /var/mail/benjamin

file mail_18_02_2006.tar.gz
should confirm that it is a tar archive - without compression really - it's just the name which suggests that it is compressed


All times are GMT -5. The time now is 04:07 PM.