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

Re: using TAR



On Fri, 2004-12-24 at 13:03 -0600, bentley.rhodes wrote:
> SO, how do i use TAR?  i have two questions ... i suppose ...
> 
> tar -c -fbackup-bntly_rhds -h -v -z /Portney/Phoenix/ /home/bntly_rhds/*
> 
> i understand, from the book, that tar will do the following:
> 
> -c                           create a new archive
> -f                           specify file name of archive
> -v                          verbosely tell me what is going on with
> Linux's funky vernicalur
> -z or -j                  compress the archive with either -z (gzip) or
> -j (bzip2), i think i've heard bzip2 is better ... so i'm curious for
> feedback on that if any.
> 
> so the above line should backup my entire directory under
> /home/bntly_rhds/ right?
> now i have a problem ... i have some softlinks in that folder (several)
> that i want to archive without backing up the actual file they are
> linked to.  i would like to simply have the link (1 byte or such)
> instead of the entire file or files (25 gigs or so).  whats the tag for
> that?
> 
> -----------------------------------------------------------------------
> 
> my second question, would be, how do i back up my entire disk, i would
> imagine it would be the same as above but with a --exclude=/home/ tag.

Bentley,

Oh, if only it were that simple... Unfortunately there are important
little things rat-holed throughout the system. It's not as bad as
Windows, but Linux backups aren't "point-and-shoot" either. With
flexibility comes complexity.

As you've seen, tar's man page explains the options fairly well, but you
don't have to use a whole lot of command line arguments to get the job
done.

I've always remembered the three basic command line arguments this way:

	Create a tarball:	tar cfv ...
	eXtract files:		tar xfv ...
	Table of contents:	tar tfv ...

You got the "fv" arguments right. In-line compression (z or j) can
really drag out the creation process. True, bzip2 (j) compresses better
than gzip (z), but unless you're extremely tight on disk space I
recommend you compress the tarball _after_ creating it using "bzip2 -9
<tarball>"

As for deciding what goes into a tarball, it helps to know what's in
each subdirectory off the root (/). It also makes some difference if
some of those are mounted filesystems.

I'm using FC3 rather than livna, but you'll get the idea. My root (/)
filesystem contains the following directories and mount points:

/bin		directory containing common binary executables
/boot		mount point for your boot-time kernel filesystem
/dev		directory containing special block and character
		device "files" (not usually backed up)
/etc		directory containing configurations (like
		/etc/bashrc, /etc/sysconfig/<many>, and so on)
/home		directory containing user home directories (duh!)
/initrd		directory containing nothing, but it must be there for
		my system to boot using an initial RAMdisk (initrd)
/lib		directory containing shared libraries
/lost+found	directory containing wreckage salvaged by e2fsck
		(like /initrd, it must be there but don't back it up)
/media		new directory in FC3 (nothing in mine)
/misc		new directory in FC3 (nothing in mine)
/mnt		mount points for system devices like /dev/fd0 and ISO
		image files (can be backed up)
/proc		virtual filesystem created at boot time (definitely
		should NOT be backed up)
/root		root's home directory separate and apart from
		/home/<users>
/sbin		directory containing root-only binary executables
/selinux	directory containing all the SELinux stuff
/srv		new directory in FC3 (nothing in mine)
/sys		new directory in FC3 populated at boot time (like /dev,
		not backed up)
/tftpboot	directory containing files used only for booting up
		across the network (PXE)
/tmp		directory _usually_ containing temporary/discardable
		files
/usr		directory containing local user stuff, especially in
		/usr/local/bin and /usr/src
/var		directory containing a lot of initialization stuff

When using tar to back up a system, I'd start with the root filesystem
and an "--exclude-from /root/exclude_file" containing /dev, /initrd, 
/lost+found, /proc, /sys, and any mounted filesystems like /boot. One
thing the man page doesn't tell you is that the format for this file is
just:
/dev
/initrd
/lost+found
...
with a UNIX <newline> (same as ASCII <linefeed>) at the end of each
line.

So... cd to a directory or filesystem with enough space and start with
the root filesystem:
# tar cfv --exclude-from /root/exclude_file root_file_system.tar /

Then create separate tarballs for each mounted directory:
# tar cfv boot_file_system.tar /boot
and so on.

Make sure you don't fill up your / filesystem creating any of these
tarballs. If you do, you'll have to boot to single-user mode and get rid
of the partial files.

Hope this helps...

-- Doc
Robert G. (Doc) Savage, BSE(EE), CISSP, RHCE | Fairview Heights, IL
Fedora Core 3 kernel 2.6.9-1.681_FC3 on a P-III/M IBM Thinkpad A22p
"Perfection is the enemy of good enough."
                         -- Admiral of the Fleet Sergei G. Gorshkov


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.