Matthew Gillen me at
Wed Aug 23 21:30:19 EDT 2006

Chris OConnell wrote:
> Hi Guys,
> I've pretty much switched to Suse entirely, but am unable to figure out
> how to perform a backup.  I assume there must be a CP parameter that
> will say "copy everything in this directory recursively (hidden files
> too) and verify them for size when you are done."
> Does anyone use a script or program they like or would be willing to
> share to backup their files to a removeable drive?

If you must use 'cp', then make sure to use 'cp -a' so that it handles
things like symlinks or device files correctly.  For some *nix foo, learn to
use 'tar'.  As someone else mentioned, rsync can be used to do efficient
updates to an existing backup.

Here's what I do for large directories (if step 1 doesn't take long, then
just use it and don't bother with step 2):
1) use tar for the the initial backup.  Assuming your files are in
/opt/somedir and you want to copy them into /backup/somedir :
 cd /opt ; tar -cvf - somedir | tar -C /backup -xf -

This copies the directory with all the advantages of using tar over cp, but
without creating the intermediate .tar file.

Why do this instead of 'cp'?  Because you can use a slight modification to
backup to remote hosts via ssh:
 cd /opt ; tar -cvf - somedir | ssh -C remotehost tar -C /backup -xf -

Pipes are fun ;-)  Pipes with ssh let you do some really whacky things.

2) for updates, or to verify that the copy is complete, use rsync:
 rsync -avz --delete /opt/somedir /backup/

Note that rsync is picky about the trailing slash on the "source" directory,
and you may or may not want the --delete option (removes files in
/backup/somedir that are no longer in /somedir).   As the man page for rsync
says: be very careful when using --delete about not getting the 'src' and
'dest' mixed up.  When using rsync from the command line, I always double
check the man page to make sure I have the arguments in the right order.


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

More information about the Discuss mailing list