12

Is there a way to do a cp but ignoring any files that may already exist at the destination that aren't any older then those files at source.

Basically I want to copy the contents of one disk to another, then run the copy again but only updating new files or files that have been updated on the source side.

Thanks

Ben Everard
  • 569
  • 3
  • 7
  • 21

3 Answers3

19

use this:

rsync -a /source /destination

Alternatively, you can get more details with a few other flags like -v or --progress.

UtahJarhead
  • 908
  • 7
  • 14
  • 2
    I want to add that you can use `rsync` over the network also. It's particularly easy to do so using `ssh`. For either the source *OR* destination, prepend it with `user@host:` and it will do just that. This will act as a replacement for `scp` – UtahJarhead Apr 17 '12 at 13:50
11

from the cp manpage:

   -u, --update
          copy only when the SOURCE file is newer than the destination file or when  the
          destination file is missing
stew
  • 9,263
  • 1
  • 28
  • 43
7

Use rsync, problem solved.

rsync -av /srcdir /tgtdir
Sven
  • 97,248
  • 13
  • 177
  • 225