SUMMARY: TAR help needed

From: sean@nmc13.chinalake.navy.mil
Date: Fri Feb 20 1998 - 10:18:48 CST


Original question:

> Dear friends-
>
> I am trying to use tar to write to a tape and then restore to a
> different directory on a different machine.
> I can only get it to restore to the original location on the original
> machine. Here is what I did.
>
> tar -c /disk13/home
>
> This created a tar on the tape. But I can restore only if I cd to
> /disk13/home and tar -x /disk13/home
>
> I want to restore to a different location and it won't work. It gives

> no error messages.
>
> Please help
> Thanks
> Sean

Thanks for the answers. I have included most of them in this summary.
My problem was caused by using absolute pathnames.

-----------------------------------------

from Michael J. Garcia

There are two solutions:
1. use gnutar.
2. cd /disk13/home; tar -c .
   This tar command will create the tar file with relative paths
   instead of absolute ones.

------------------------------------

While doing tar you are giving complete path i.e from /
Use ./ instead of / (tar -c ./disk13/....)
and you will be able to restore it where ever you want.

Hope you got it.

reg
Mohan Movva.

--------------------------------------

From: JOSEPH AAJ Chackompally <AAJ@necsin.nec.com.sg>

Dear Sean,

Please use relative path for this
What you can do is
before taking the backup

change to the directory /disk13/home
then do tar -cvf /dev/TAPE_DRIVE .
this will help you in copying the contents of the directory called
/disk13/home into the device specified under TAPE_DRIVE (use the
proper device name)
now whatever has been copied to the tape is copied with just the
relative path name
that means this will contain only the file names

you can restore this any where

if you want to restore it under /home/myname of other machine
then cd to /home/myname
do tar -xvf /dev/TAPE_DRIVE

that is all

If you want to keep the directory structure of /disk13/home
then what u can do is
go to the first machine
cd /
tar -cvf /dev/TAPE_DRIVE disk13/home
never use (/disk13/home)

restore this in other machine under /home/myname
you will get the files as

/home/myname/disk13/home/file1
/home/myname/disk13/home/file2 etc
where file1 file2 etc are the different files which were present under
/disk13/home of the first machine

Thanks and Regards
Aaj

PS : for any clarification mail me
aaj@necsin.nec.com.sg

--------------------------------------

From: "Brion Leary" <brion@dia.state.ma.us>

Sean

Instead do

cd /disk13 ; tar -c ./home

This will create a tar file of directory home which you can untar
as home on another machine.

or ... cd /disk13/home ; tar -c .

This will create a tar file of the contents of home which you may
untar into some other directory.

----------------------------------------

From: Eugene Kramer <eugene@uniteq.com>

cd /
tar cvf /dev/rmt/<tape> disk13/home

 or you can do

cd /disk13/home first and then tar '.'

Eugene

-------------------------------------------

From: Derrick Lim <bklim@penang.csam.com.my>

Hi Sean,

You are using absolute path for tar, which when extracting, the tar will

extract the files back to the directory as in absolute path. You should
use relative path in this case.

Your tar command may look like this :

# cd /disk13
# tar -c home

------------------------------------------------

ieee.....

You created the tape with absolute paths .....

O.k. here's a fix I posted a couple of days ago to someone else....
 # cp /usr/sbin/static/tar /tmp
 # dd if=/dev/nrst0 | chroot /tmp tar xvf -

gnu tar has an option built in for this, solaris tar doesn't......

Simon

--------------------------------------------

Change directories to /disk13/home, then "tar -c ../FILENAME.tar .".
You can then move this to another machine, cd to the destination
directory, and do a "tar -x /LOCATION/OF/FILENAME.tar". Your problem
is that the fully qualified path is stored in the tar file.

-------------------------------------------------------------
Tim Fritz, Unix Sys Admin
Easy. Just do "cd /disk13; tar c ./home" and you can put it anywhere
you want. Remember: never use tar with an absolute path. This is a
UNIX gotcha from way back.

Regards,

Dan Lorenzini

don't use a leading slash.
Use: cd /; tar -c disk13/home

Brian
From: Stephen Frost <sfrost@mitretek.org>
Subject: Re: need tar help
Mime-Version: 1.0

 Never call tar w/ an absolute pathname, NEVER. :) Your command should
look something like this:

 (cd /disk13/home; tar -c .)

 Then to restore:

 (cd /wherever; tar x)

 Now, if these are on the same machine you can do that in one step:

 (cd /disk13/home; tar cvf - .) | (cd /wherever; tar -xvf -)

 Or if on different machines w/ .rhosts set up correctly:

 (cd /disk13/home; tar -cvf - .) |
 rsh remotemachine "(cd /wherever; tar -xvf -)"

 Note that that is one command, just sepperated at the pipe to fit on
the
screen easier.
Sean,

If possible recut the tape. Use the following steps:

 cd /
 tar -c disk13/home

The leading slash makes the tar lock to root "/". Removing it will
allow you to relocate the files on extract. If you can't recut the
tape, gnu tar can strip off the leading /. I also have a perl script
that will do the same thing. Let me know if you need it.

--
  John M. Vogtle (jmvogtle@kodak.com)         | Eastman Kodak Company

From: Seth Rothenberg <SROTHENB@montefiore.org>

Sean, To be able to restore to another directory, create the tar file as a relative file.

cd /disk13 tar cf disk13.tar ./home

then cd /disk21; tar xfv disk13.tar to create /disk21/home

PS...If you have a network, you can do the following: cd /disk13; tar cbf 10 - . | \ rsh remotehost '(cd /disk21; tar xbfv 10 -)'

Note, the block size of 10 is nice to the network. The single quotes (below the " on the keyboard) is necessary. This is based on a same-machine example in "man tar"

Here are a couple of ideas you could use. . . 1. My first idea was to re-do your tar, and make sure it isn't an absolute tar file. . .then do a 'pipe-tar' on to the tape and then into another directory. .. 'tar cvf /dev/rmt/0 'filename' | (cd /'directory';tar xvf - ) 2. If you don't want to re-do your tape, look at the manpage for 'chroot'

Hope this works. . .it kind of stumped me too for a while. . .

-- \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Sean Harvey OAO Corp sean@nmc13.chinalake.navy.mil Ridgecrest CA (619)939-2199

Affluenza: The virus of overconsumption. Symtoms include not realizing one has enough and the continual pursuit of more.

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:31 CDT