LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2009, 09:08 AM   #1
just a man
Member
 
Registered: Feb 2009
Posts: 37

Rep: Reputation: 15
Can you spot the error in my tar command?


I'm using the following command in a script run by crontab to backup my server...

Code:
#!/bin/bash

tar -cvpzf server.tar.gz --exclude=/home/jam/server.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/home/jam/backup --exclude=/home/jam/stuff /

HOST='backupbox.net'
USER='jam'
PASSWD='marmalade'
FILE='server.tar.gz'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit

#rm -rf /home/jam/server.tar.gz

END_SCRIPT
exit 0
/home/jam is my home directory, and backupbox.net is another server on which I have an account that I access via ftp to store the backup, and those "--exclude" directories are just directories I don't want in the backup. Aside from them everything under "/" is supposed to be backed up.

The command does actually create the file server.tar.gz, and sends it to the backup server ok. But if I try to open the archive on the Ubuntu Desktop of the server making the backup, I get this error:

Quote:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Exiting with failure status due to previous errors
If I run
Code:
tar -tv ./server.tar.gz
on the command line in Terminal to just list the contents of the archive, it just hangs.

Any body can give me a clue what I'm doing wrong? Or is there just a limit to the size of archive that tar can reliably create?

Last edited by just a man; 12-16-2009 at 09:22 AM.
 
Old 12-16-2009, 09:33 AM   #2
mlev
LQ Newbie
 
Registered: Dec 2009
Posts: 10

Rep: Reputation: 1
I don't think tar -tv lists files in a .gz archive. Instead use:

tar -ztvf server.tar.gz

(The "z" and "f" inform tar that it is working with a gzip file? Anyway, it should work.)

Your tar command looks OK to me, but I can't see the entire line in the post. (Looks like the words didn't wrap.)
 
Old 12-16-2009, 09:44 AM   #3
just a man
Member
 
Registered: Feb 2009
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by mlev View Post
I don't think tar -tv lists files in a .gz archive. Instead use:

tar -ztvf server.tar.gz

(The "z" and "f" inform tar that it is working with a gzip file? Anyway, it should work.)

Your tar command looks OK to me, but I can't see the entire line in the post. (Looks like the words didn't wrap.)
Thanks for the response, if you scroll-bar along to the end it ends "--exclude=/home/jam/stuff /", that is the last exclude, and to archive "/", trying to archive everything else under root except that which is excluded.

I tried your command, and now get a consistent error message, that being the same one as when I try to view the archive via Ubuntu Desktop:

Quote:
sh-4.0$ tar -ztvf server.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Exiting with failure status due to previous errors
sh-4.0$
 
Old 12-16-2009, 10:15 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
humour me, and try
tar -zcpf etc. or even
tar -c -z -p -f etc.

Reasons: the '-v' option isn't implemented for making archives, only for extracting; The tar info page (a contender for the most obscure document on the planet) suggests that clustering options is bad news, and they would like if getopt actually threw that out as an invalid format. My guess is they have problems there. The '-z' option is fussy if it's not at the beginning.
 
Old 12-16-2009, 10:55 AM   #5
mlev
LQ Newbie
 
Registered: Dec 2009
Posts: 10

Rep: Reputation: 1
I don't think there's an error in your tar command. I created a script like yours and it runs fine. (The "v" causes the list of files being compressed to scroll on the terminal.)

Maybe a corrupt file or directory is throwing tar into a tizzy.
 
Old 12-17-2009, 03:58 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Tar -tz never works - try it people.

The -z option likes to be near the front of a string of options or it doesn't work.
I don't think -cvpzf is ok, use -cz -pvf or the like
 
Old 12-17-2009, 04:26 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Quote:
Originally Posted by business_kid View Post
Tar -tz never works - try it people.

The -z option likes to be near the front of a string of options or it doesn't work.
I don't think -cvpzf is ok, use -cz -pvf or the like
"tar -tz" and "tar -cvpzf" work fine for me.
Code:
% tar --version
tar (GNU tar) 1.22
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
What version of tar are you using?

Evo2.
 
Old 12-17-2009, 04:27 AM   #8
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Quote:
Originally Posted by just a man View Post
I'm using the following command in a script run by crontab to backup my server...
I think paths can get a bit screwy with cron. Have you tried just running the script manually?

Cheers,

Evo2.
 
Old 12-17-2009, 04:30 AM   #9
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Quote:
Originally Posted by just a man View Post

If I run
Code:
tar -tv ./server.tar.gz
on the command line in Terminal to just list the contents of the archive, it just hangs.
You need z and f
Does this work?
Code:
tar -tzvf ./server.tar.gz
Evo2.

Last edited by evo2; 12-17-2009 at 04:35 AM. Reason: Opps, verbose list is ok
 
Old 12-17-2009, 06:49 AM   #10
just a man
Member
 
Registered: Feb 2009
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by evo2 View Post
You need z and f
Does this work?
Code:
tar -tzvf ./server.tar.gz
Evo2.
Woah, yes it does!

If this works, then maybe the archive is ok?
 
Old 12-17-2009, 06:51 AM   #11
gottymann
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
installing xfce on ubuntu 9.10

installing xfce on ubuntu 9.10
 
Old 12-17-2009, 06:52 AM   #12
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Quote:
Originally Posted by just a man View Post
Woah, yes it does!

If this works, then maybe the archive is ok?
Try it. Just replace the t with x.

Evo2.
 
Old 12-17-2009, 07:16 AM   #13
kofucii
Member
 
Registered: May 2007
Location: Bulgaria
Distribution: Slackware, SCO Unix
Posts: 62

Rep: Reputation: 20
I don't think you can tar the special files like /dev, /proc/, /sys. To do so, try with command "cpio".
 
  


Reply

Tags
archive, tar


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
F-Spot fatal error downloading Nikon D700 via ISB? brianpbarnes Linux - Software 3 12-20-2008 10:22 AM
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-13-2008 11:27 PM
qmail (LWQ) installation error *spot the n00b* dannyboynslu2 Linux - Software 1 07-30-2005 11:00 AM
tar command : error: file changed as we read it sneezesnoeze Linux - General 2 04-05-2004 06:56 PM
Can anyone spot the error in this cron file? Pcghost Linux - Software 6 07-23-2003 02:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration