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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-16-2009, 09:08 AM
|
#1
|
Member
Registered: Feb 2009
Posts: 37
Rep:
|
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.
|
|
|
12-16-2009, 09:33 AM
|
#2
|
LQ Newbie
Registered: Dec 2009
Posts: 10
Rep:
|
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.)
|
|
|
12-16-2009, 09:44 AM
|
#3
|
Member
Registered: Feb 2009
Posts: 37
Original Poster
Rep:
|
Quote:
Originally Posted by mlev
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$
|
|
|
|
12-16-2009, 10:15 AM
|
#4
|
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545
|
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.
|
|
|
12-16-2009, 10:55 AM
|
#5
|
LQ Newbie
Registered: Dec 2009
Posts: 10
Rep:
|
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.
|
|
|
12-17-2009, 03:58 AM
|
#6
|
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545
|
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
|
|
|
12-17-2009, 04:26 AM
|
#7
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by business_kid
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.
|
|
|
12-17-2009, 04:27 AM
|
#8
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by just a man
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.
|
|
|
12-17-2009, 04:30 AM
|
#9
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by just a man
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
|
|
|
12-17-2009, 06:49 AM
|
#10
|
Member
Registered: Feb 2009
Posts: 37
Original Poster
Rep:
|
Quote:
Originally Posted by evo2
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?
|
|
|
12-17-2009, 06:51 AM
|
#11
|
LQ Newbie
Registered: Dec 2009
Posts: 2
Rep:
|
installing xfce on ubuntu 9.10
|
|
|
12-17-2009, 06:52 AM
|
#12
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by just a man
Woah, yes it does!
If this works, then maybe the archive is ok?
|
Try it. Just replace the t with x.
Evo2.
|
|
|
12-17-2009, 07:16 AM
|
#13
|
Member
Registered: May 2007
Location: Bulgaria
Distribution: Slackware, SCO Unix
Posts: 62
Rep:
|
I don't think you can tar the special files like /dev, /proc/, /sys. To do so, try with command "cpio".
|
|
|
All times are GMT -5. The time now is 04:32 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|