7

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.

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

3 Answers 3

12

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/
4
  • Normally I'd add "-e ssh" to that last one. I don't like running an rsync server because it's not secure enough. Nov 5, 2009 at 21:40
  • 1
    I was under the impressions that rsync uses ssh by default. I think you need two colons to specify an rsync server. Nov 5, 2009 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. Nov 5, 2009 at 22:51
  • 1
    Yeah, it uses ssh by default. Need to add more "options" for rsync. Funny huh? Nov 5, 2009 at 23:14
10
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

3

My brain couldn't quite cope with the complexities of rsync so I installed Lucky Backup. This provides an easy to use graphical interface as a front end for rsync. When you've set up your copy/backup task, you can run it from the programme. You can also click on the "validate" button for the task and it will give you the full rsync command line such that you can run it in a terminal or paste it into a shell script. It's a nice tool for teaching the use of rsync.

Screen Shot of Lucky Backup

Clicking on the "Advanced" button in the "Task Properties" window gives access to some of rsync's features.

2
  • 1
    Can you expand upon your answer with some screenshots? Your answer reads a bit like spam.
    – bwDraco
    Apr 7, 2015 at 16:31
  • I tried to add a screenshot but the system demanded I had at least 10 reputations! I have added a link instead.
    – Gannet
    Apr 11, 2015 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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