[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: tar question from newbie



On Mon, 17 Jun 2002, Abner Gershon wrote:

> This is very frustrating. I have 3 Linux books that I have consulted
> as well as the man page and I can't figure out how to use tar to back
> up my /home directory from where it resides on /dev/hdd to my other
> hard drive /dev/hdb7.
> 
> I accidentaly ran fsck today without making the file system read only
> which I later read was a no no and I am wondering if this may have
> lead to a problem. I never received any message that any of the files
> were damaged though.

The past participle of the verb "to lead" is "led", not "lead".  Sorry,
but that's a peeve of mine.  I hope you'll forgive me for being so
pedantic, given what comes next :)

> Anyway I change to my home directory, "cd /home". Then type "tar -cf
> /mnt/abner" (I previously mounted /dev/hdb7 to /mnt)

Here's my favorite magic tar command:

tar cf - <dir1> | (cd <dir2>; tar xvf - )

It copies <dir1> to <dir2>, preserving everything, including symbolic
links.  The "-" in the first half sends everything to STDIN; the "-" in
the second half accepts input from STDOUT.  And, because it uses stdin and
stdout, it doesn't require disk space to work.

In your case, from the / directory, replace <dir1> with /home, <dir2> with
/mnt/abner.  You might want to run it with 'tar tvf -' on the right side
of the pipe first, just to see what it's going to do.  The "v" in the
"xvf" on the right side is unnecessary - I just like to see what's going
on.

This comes, by the way, from _The Underground Guide to Unix_, by John
Montgomery (Addison-Wesley 1994).  I recommend it.  I just checked Amazon,
and it's available at

http://www.amazon.com/exec/obidos/ASIN/0201406535/qid%3D1024368156/ref%3Dsr%5F11%5F0%5F1/102-2544833-3769763

Patrick

-- 
Patrick Wiseman
pwiseman@mindspring.com
Linux user #17943


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: