Operating System - HP-UX
1819906 Members
2480 Online
109607 Solutions
New Discussion юеВ

Use of tar xvf and tar cvf

 
SOLVED
Go to solution
telco_1
Advisor

Use of tar xvf and tar cvf

Hi ,

I am using HP-UX 11.11
I have some of my file test.tar tar in /opt directory.
Now i want to untar them into /var/test1 directory.

So should i use
tar xvf test.tar -C /var/test1

or how can i untar them so that the untared files go to var directory from /opt.
12 REPLIES 12
MarkSyder
Honored Contributor
Solution

Re: Use of tar xvf and tar cvf

cd /opt
cp -p test.tar /var/test1
cd /var/test1
tar xvf test.tar

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Peter Godron
Honored Contributor

Re: Use of tar xvf and tar cvf

Hi,
I would also do a :
tar -tvf test.tar
just to check that no absolute path was used for the tar creation.

Telco,
please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28

You profile shows 0 points awarded for 23 answers !
V. Nyga
Honored Contributor

Re: Use of tar xvf and tar cvf

Hi,

it ONLY works if the tar file was created with relative pathes: './opt/...'.
You have to check it with 'tar tvf ...' or recreate the tar file with 'tar cvf ./opt/...'

Aslo note that the path opt will be created too in your /var/test1 directory.

Volkmar
*** Say 'Thanks' with Kudos ***
Steven Schweda
Honored Contributor

Re: Use of tar xvf and tar cvf

What you need to do depends on how you did
the "tar c..." to create the archive.

Some output from "tar xvf test.tar" would be
helpful.

And where is "test.tar"?
A. Clay Stephenson
Acclaimed Contributor

Re: Use of tar xvf and tar cvf

If you specified the files to be backed up with tar using absolute paths then it is extremely non-trivial to restore them to another location using tar. You have to chroot and then tar but there is a much simpler way. Use the pax command (which can read tar files) and use the -s option to rename the files. Man pax for details.
If it ain't broke, I can fix that.
Steven Schweda
Honored Contributor

Re: Use of tar xvf and tar cvf

Oops.

> Some output from "tar xvf test.tar" would be
> helpful.

Make that:

Some output from "tar tvf test.tar" would be
helpful.
Cem Tugrul
Esteemed Contributor

Re: Use of tar xvf and tar cvf

Hello,
AS an addition to other precious replies;

KBRC00000197 [This document may be viewed by customers]
[This document has been certified]
Example backup/recover commands for fbackup, cpio, tar
Document Information Table
Example backup/recover commands for fbackup, cpio, tar
DocId: KBRC00000197 Updated: 1/3/00 8:52:22 AM

PROBLEM

The most frequently used commands for fbackup, cpio, tar.

** edited to comply with forum guidelines **

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
telco_1
Advisor

Re: Use of tar xvf and tar cvf

Thanks a lot to all of you for you swift replies :)

well now when i m untaring the files i m getting error

Directory chekcsum error
Peter Godron
Honored Contributor

Re: Use of tar xvf and tar cvf

Hi again,
can you please detail:
1. Exactly what command was used to create the tar file (I assume it was on the same machine)
2. What was the result of using tar -tvf test.tar
3. Is the same version of tar being used?


For same problem reports please see:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=419346
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=327706
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1047670
Steven Schweda
Honored Contributor

Re: Use of tar xvf and tar cvf

> Directory chekcsum error

I see this most often when I'm not looking
at a real "tar" archive.

If you would show the actual commands you
use, with the actual input and output, it
might be easier to provide some more useful
answers.
Frank de Vries
Respected Contributor

Re: Use of tar xvf and tar cvf

Checksum errors are a killer.

Maybe you are better off doing a tar pipeline
creating at source dir and extracting at target dir in one action, rather then first
creating a tar file.

change to /opt>

tar cf - . | (cd /var/test1; tar xvf - )

This means tar all files in current dir
and extract in target dir.




Look before you leap
Bill Hassell
Honored Contributor

Re: Use of tar xvf and tar cvf

Where did you create the tar file? On another system? Did you use ftp to transfer the file? Or was a PC involved in transferring the file? Did you forget to change from ASCII to BINARY mode to transfer the tar file? This is a crucial step. ftp will corrupt binary files when transferring them in ASCII mode.


Bill Hassell, sysadmin