vote up 0 vote down star

Windows has a nice option to its XCOPY command: /D. This copies only files where the source modification time is newer than the destination time. Is there any unix/linux equivalent of this? I'm trying to get a fast copy to my local testing server.

flag
This should be asked on SuperUser as it has nothing to do with programming. – SLaks Nov 5 at 21:34

migrated from stackoverflow.com

2 Answers

vote up 5 vote down check

I usually do:

rsync -avz /from/where/ /to/dest/

If you want it to delete files that doesn't exist anymore in /from/where add --delete.

It can also be used from different boxes like this:

rsync -avz eromero@mydevbox.org:/from/where/ eromero@mybox.org:/to/dest/
link|flag
Normally I'd add "-e ssh" to that last one. I don't like running an rsync server because it's not secure enough. – Paul Tomblin Nov 5 at 21:40
I was under the impressions that rsync uses ssh by default. I think you need two colons to specify an rsync server. – Ryan Thompson Nov 5 at 22:39
Oh yeah, you might want to throw in the --update option, if you don't want to overwrite newer files in the destination, but only older ones. It depends on whether you just want to efficientlysynchronize the two directories, or you want the exact behavior described above, with modification times. – Ryan Thompson Nov 5 at 22:51
Yeah, it uses ssh by default. Need to add more "options" for rsync. Funny huh? – Eduardo Romero Nov 5 at 23:14
vote up 7 vote down
cp --update src dest

From the man page:

copy only when the SOURCE file is newer than the destination file or when the destination file is missing

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.