Copying directory trees only for new files

Anthony Atkielski atkielski.anthony at wanadoo.fr
Sun Jan 9 15:08:38 PST 2005


What's the safest and most elegant way to copy an entire directory tree
such that only newer files and directories are actually copied?

Essentially I have one directory that contains my test version of my Web
site, and another directory that contains the production version of the
site.  Normally the two directories are mirror images of each other.
When I update one or more files in the test tree, I want to have some
easy and safe way to copy the test tree to the production tree--but for
efficiency's sake, I only want to actually physically copy the data for
a file or directory if the source version has been modified more
recently than the destination version.

The cp command looks like it would do the trick, except it doesn't
appear to have any option that copies only newer files and directories.

I suspect there are probably a dozen or more UNIX commands that do this
sort of thing, and/or perhaps some FreeBSD-specific commands that do it
as well. Any suggestions on which commands to look at?

If I can get this to work cleanly and in a straightforward way I may be
able to liberate myself from the creaky old copy of Visual InterDev that
I use for Web development.  UltraEdit (which I use on Windows) will let
me edit files directly to and from an FTP destination, so I could use
that to make my changes, then use a magic command to copy the changed
files from the test tree to the production tree once I've tested them.

-- 
Anthony




More information about the freebsd-questions mailing list