1827275 Members
2214 Online
109717 Solutions
New Discussion

Tar trouble!

 
SOLVED
Go to solution
David Heath_1
Advisor

Tar trouble!

Hope someone can help!

I have two machines and need to copy the home area of one and transfer it to the other. Basically, I have tried to tar the home using the following command.

tar -cvf /home/home.TAR /home

However, this tars fine until it trys to tar the actually tar I am making and so fills the up the home area and runs out of space. I have tried to tar it to a different file system such at /tmp but there isn't enough space in there and that then fills up. How can I tar the home area with out the tar file getting stuck tarring itself?!

Oh and I cant stick it on a tape either!
Can I make a list of all the file names or something and then make the tar read the names of these files and tar the files, maybe?!!
Many thanks, David,
29 REPLIES 29
Nobody's Hero
Valued Contributor

Re: Tar trouble!

Try your tar from another directory. Are you in the /home directory when you run the tar?
go to /
run > tar -cvf /home/home.tar /home

Bob
UNIX IS GOOD
Helen French
Honored Contributor

Re: Tar trouble!

Hi David,

If you have NFS configured on the system, then mount the other /home file system on your original server and copy the files using cp, cpio etc.

eg: find /source_dir -depth | cpio -pdlmuva /dest_dir

HTH,
Shiju
Life is a promise, fulfill it!
Nobody's Hero
Valued Contributor

Re: Tar trouble!

What I mean is,
tar -cvf home.tar /home
UNIX IS GOOD
Christopher McCray_1
Honored Contributor

Re: Tar trouble!

Just for my understanding, for tmp you tried:

# tar cvf /tmp/home.TAR /home

If that is the case and you still don't have room, try to find another filesystem with room, increase /tmp, if possible.

How about rcp?

Just my thoughts, hope they help

Chris
It wasn't me!!!!
Steven Sim Kok Leong
Honored Contributor

Re: Tar trouble!

Hi,

You can use the wildcard * instead. As long as you can perform

# ls /home/*

then this will work.

If you use the wildcard *, the shell will expand it before the tar gets executed.

# tar -cvf /home/home.TAR /home/*

This will prevent home.TAR from tar'ing itself subsequently.

Hope this helps. Regards.

Steven Sim Kok Leong
David Heath_1
Advisor

Re: Tar trouble!

Whoa! Thanks for all the quick replies!

Unfortunately I cant extend the filesystems, there not my machines. I was hoping there would be an easier solution than extending them all.


I am doing the tar from outside the home directory,
tar -cvf /home/home.TAR /home

And yes when I was in /tmp I did
tar -cvf /tmp/home.TAR /home

Cheers fo all your helps,
points coming soon!

David
Andreas Voss
Honored Contributor

Re: Tar trouble!

Hi,

with the combination of find and cpioyou can get it work like this:

find /home ! -name home.CPIO -depth | cpio -oc >/home/home.CPIO

On the other machine do:

cpio -imdc
Regards
harry d brown jr
Honored Contributor

Re: Tar trouble!

Why not just use rcp? Especially if you are moving this to another machine?

live free or die
harry
Live Free or Die
David Heath_1
Advisor

Re: Tar trouble!

Ok I am tarring from outside of /home as we speak.

If this doesn't work will the wildcard command transverse througout symbolic links to other machines? The home directory has about 10 different links to different machines, which I dont want to be added to the tar?

Thanks all.
Robin Wakefield
Honored Contributor

Re: Tar trouble!

Hi David,

One way:

# create the tar
find /home -type f | head -1 | xargs tar cvf /home/home.TAR
# then add the rest...
find /home ! -name "home.TAR" -type f | tail +2 | xargs tar rvf /home/home.TAR

Rgds, Robin.
Craig Rants
Honored Contributor

Re: Tar trouble!

Try

tar cvf - /home | gzip > /tmp/home.tar.gz

This should save a lot of space and time.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Helen French
Honored Contributor

Re: Tar trouble!

Hi David,

Do a 'bdf' and findout a file system which has free space on it. Then try a tar.

# tar -cvf /test/home.tar /home

HTH,
Shiju
Life is a promise, fulfill it!
Steven Sim Kok Leong
Honored Contributor

Re: Tar trouble!

Hi,

If you have other filesystems such as nfs-mounted filesystems within /home, then:

# tar cvf home.tar `find /home -xdev -print`

-xdev will prevent the files in other filesystems other than /home from being listed.

Hope this helps. Regards.

Steven Sim Kok Leong
David Heath_1
Advisor

Re: Tar trouble!

Ok!! Too many answers to keep up with.

I tried tar'ing from outside the directory - same problem, the tar tries to tar itslef fills up /home.

/home is the largest filesystem on the machine with 600mb of data out of 1GB.

The wildcard solution didn't work because I couldn't do a ls /home/*.

The CPIO command didn't work wither.

How can I do rcp?

Thanks.
Andreas Voss
Honored Contributor

Re: Tar trouble!

Hi,

the use of rcp could be:

rcp -rp /home :/

Regards
Helen French
Honored Contributor
Solution

Re: Tar trouble!

Hi David,

Check this out for help in rcp:

http://www.docs.hp.com/hpux/onlinedocs/B2355-90148/B2355-90148.html

HTH,
Shiju

Life is a promise, fulfill it!
harry d brown jr
Honored Contributor

Re: Tar trouble!

Go to the directory


rcp -rp /home/directory2Bcopied remothostname:/home

like this:

cd /home
rcp -rp ./harry otherhost:/home

live free or die
harry
Live Free or Die
Christopher McCray_1
Honored Contributor

Re: Tar trouble!

Hello again,

First make a /.rhosts file on both machines(if doesn't exist)

add the following entries:

root host1
root host2

save it. Also, make sure that the entries for login, shell and exec are not commented out in your /etc/inetd.conf and /etc/services files. If they are, uncomment them and run inetd -c.

then on host1:

# rcp /home/* host2:/home

Hope this helps
Chris
It wasn't me!!!!
Christopher McCray_1
Honored Contributor

Re: Tar trouble!

oops, of course rcp -rp!!

Good luck
Chris
It wasn't me!!!!
Steven Sim Kok Leong
Honored Contributor

Re: Tar trouble!

Hi,

>> The home directory has about 10 different links to different machines, which I dont want to be added to the tar?

Since you have 10 different links to different machines, what is preventing you from creating one more link to just this one more machine you need to copy the data to? :)

Once the link is created, you can simply use cp or cpio (as indicated in above posts) to copy over direct.

Hope this helps. Regards.

Steven Sim Kok Leong
Carlos Fernandez Riera
Honored Contributor

Re: Tar trouble!


try this one:

tar cf - /home | compress > /tmp/compressed_tar_file.tar.Z

Reverse ( extract):

uncomppres /tmp/compressed_tar_file.Z | tar xf -

Good luck.
unsupported
Carlos Fernandez Riera
Honored Contributor

Re: Tar trouble!

Eh... i forget that /home can contain links to other(s) filesystems


tar cf - ` find /home -xdev -type f ` | compress .....

unsupported
Steve Steel
Honored Contributor

Re: Tar trouble!

Hi


Another idea

From the one machine:

cd
tar cf - . | remsh "cd ;tar xvhHlpf -"

The first is the top of the directory structure you want to copy
from the source machine. The is the hostname of the second
machine. The second is the path where you want to copy the data
to on the destination machine.

If you do not care about using tar or the intermediate writing to tape,
then using ftp(1) or rcp(1) to copy files between remote systems is easier
than the procedure outlined above.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Darrell Allen
Honored Contributor

Re: Tar trouble!

Hi David,

I know you got a lot of replies to your question and sense you may have been getting confused. I'll try to answer the questions you raise concerning tar.

By the way, if you're not running as superuser, the last paragraph below is going to tell you all you need to know.


<>

rm /home/home.TAR
tar -cvf /home/home.TAR /home/*

This tells tar the input files are every file and directory in /home. The wildcard "*" is expanded by the shell then passwd to the tar command. You must remove /home/home.TAR first or it will be seen when the shell expands the wildcard.

If you have some files or directories in /home (not its sub-directory structure) then you could append " /home/.[0-9a-z]*" to the tar command line. Don't specify .* because that would include your current and parent directories as well.


<>

Yes, but I believe using wildcards as above is more straight-forward.


<tar -cvf /home/home.TAR /home>>

Since you specify the absolute paths, it doesn't matter which directory you cd into before running this command. The archive will still be in /home and you are specifying the input to be the entire /home structure. home.TAR will be created then included in the archive (as you have discovered).


<>

man tar says that the default behavior of tar is to not follow symbolic links. This means your symlinks will be archived, not the files they point to. Use -h to for tar to follow symlinks.


<
>

If this means that 600MB is used, then tar by itself is going to fill up /home. tar is an archival tool, not a compression tool. However, using Craig's suggestion along with Steven's will probably save enough space to work:

rm /home/home.TAR
tar -cvf - /home/* | gzip >/home/home.TAR.gz

The "-" after cvf tells tar to use standard output as the archive file. That is piped to gzip which compress it and save the output to /home/home.TAR.gz.

The easiest way to extract the contents of home.TAR.gz is:
gzip -dc home.TAR.gz | tar -xvf -

This save space as the decompression is performed inline and not written to disk.


<>

If you can not list the contents of /home's sub-directories, then you aren't going to be able to archive them. Are you running as superuser? If not, forget the whole thing. You don't have the appropriate permissions!

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)