tar in a script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers tar in a script
# 1  
Old 05-07-2008
tar in a script

I am trying to write a simple script where I tar a few files and send them to tape

The code looks like this:

tar -cvf archive/tam/*20080507* archive/sam/*20080507* source/delta/*20080507*

This runs fine from the command line but when i try to run this in a script I get an end of tape error.

Anyone know whats wrong ???

Thanks
Zapper
# 2  
Old 05-10-2008
the syntax: is tar -cvf <destination like tape drive or tar file> <files to backup>

example: tar -cvf /dev/rmt/0 /etc /var # will backup /etc and /var to tape drive /dev/rmt/0

tar -cvf /tmp/ball.tar /etc /var # will backup /etc and /var to a file called /tmp/ball.tar

what you are doing tar -cvf archive/tam/*20080507* archive/sam/*20080507* source/delta/*20080507*

is being interpreted as trying to backup archive/sam/*20080507* & source/delta/*20080507* to a file called *20080507* inside archive/tam/

And maybe the error that's coming is not tape as it's not show you specified a tape device. Probably the error is trying to tell you that it's out of space. do a df -k and check the folder where "archive" located, I think it may be 100% full.

the clean way to tar a few files from different location.

example if I wanted to backup all the files under archive
cd /archive

ls -1 * > /tmp/xxx

tar -cvf /dev/rmt/0 `cat /tmp/xxx`

cd /
# 3  
Old 05-10-2008
Ok thanks
So I am wondering why this works from the command line
From what you are saying, I have to specify the tape drive if I am doing this from a script but from the command line it interprets the tape drive on its own somehow ??

Zapper
# 4  
Old 05-11-2008
zapper222:

Could it be that you didn't specify "f" on the CLI? If so, then tar sends its o/p to the first tape drive by default.

tar's behavior could be different on your platform, but this holds true for Solaris (/dev/rmt/0).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

2. UNIX for Dummies Questions & Answers

Script help - TAR

*****CAN'T CHANGE THE TOPIC NAME******** I'm using "zip" instead Hi. I'm trying to make my script use "zip" and i want it to compress all the files in a directory to individual zip files... but i can't really figure out how. i have googled around. tried some different things... but i can't get... (6 Replies)
Discussion started by: vYN
6 Replies

3. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

4. Shell Programming and Scripting

Need help with tar script

The following script is supposed to look at a list of files and folders and tar them all up. Ofcourse you have to strip off everything to the left of the file or folder to tar only that object. My problem is that when I do that my script no longer knows how to find the file or folder. Is there a... (0 Replies)
Discussion started by: mj12net_brian
0 Replies

5. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

8. Shell Programming and Scripting

using tar via su in a script issue !!!

I am trying to implement the below command in my shell script su - $PROCESS -c `tar -tvf $file|tee -a $LOG/$file.log` The idea is to get the tar output on the screen and at the same time it should put the output in the log file. Problem is: 1) I donot get the output on the screen. 2)... (3 Replies)
Discussion started by: kpatel786
3 Replies

9. UNIX for Advanced & Expert Users

Tar utility (untar a .tar file) on VxWorks

Hi All Can someone pls guide me if there any utility to compress file on windows & uncompress on vxworks I tried as - - compressed some folders on windows ... i created .tar ( to maintain directory structure ) and compressed to .gz format. - on VxWorks i have uncompressed it to .tar... (1 Reply)
Discussion started by: uday_01
1 Replies

10. Shell Programming and Scripting

how to write script in tar

i have the script.in this script comprees formatlike tar and insert to another directory and another sever.and how to write this process in script . iam new for unix how to do this process. please helpmea naveen.g (1 Reply)
Discussion started by: naveeng.81
1 Replies
Login or Register to Ask a Question