Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'How to use 'cp' as a simple but reliable backup tool' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to use 'cp' as a simple but reliable backup tool
Authored by: kiltbear on Feb 17, '10 09:39:11AM
I think cp with these options will overlook changed files, my favorite for stuff like this is rsync. Here's my cheatsheet for rsync, read the man page for it though...

rsync -avhP source destination

a=archive,
v=verbose,
h=human readable,
P=save intermediate Partial files (--partial) and give you Progress (--progress)

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:

rsync -avhP /src/foo /dest

copies "foo" itself to /dest directory creating a foo subdirectory

rsync -avhP /src/foo/ /dest/foo

copies "foo/*" to /dest directory implicitely forcing the creation of "foo" at the destination

rsync -avhP /src/foo/ /dest

puts the contents of foo into /dest with no "foo" directory

[ Reply to This | # ]