2

I've copied a large directory to another location (through a network). I needed to preserve all the timestamps (especially ctime and mtime). However somewhere in the process I screwed things up. (I probably made a typo in the flags.) And all the files have new timestamps now. I still got the directory with the correct timestamps. But I don't want to copy it all again because it took me days. Can I somehow just sync the filestamps, e.g. with rsync? Note that this has to be done through a ssh tunnel over a network that is rather slow. The PCs on both ends however are quite fast.

1 Answer 1

2

Yes, rsync is your best bet. Something like this should work:

rsync -vr --size-only --times <source> <dest>

--size-only tells rsync not to copy the files again, --times tells it to update timestamps.

5
  • The "--size-only" will work but I don't think it's necessary. The regular rsync algorithm (comparing checksums) will work just fine.
    – RJHunter
    Commented Jul 4, 2016 at 8:53
  • @RJHunter Did you actually try it? It will re-transfer the files, because the timestamps differ. Commented Jul 4, 2016 at 9:00
  • If rsync does "re-transfer" a file, it's usually very fast and uses little data. The rsync protocol is specifically designed to transmit only a small amount of data when both sides have similar or identical files. This is the "speedup" that rsync prints on completion. (Note that the rsync tool doesn't bother with delta-transfer when syncing local-to-local, because this is only a benefit over a network.)
    – RJHunter
    Commented Jul 4, 2016 at 14:16
  • @RJHunter From the OP: I've copied a large directory to another location (through a network). Commented Jul 4, 2016 at 14:18
  • Indeed, the OP will benefit from the speed-up of delta-transfer because of the network, as long as rsync is being used in its normal network mode. Copying from a mounted network share to a local disk would be "local-to-local" as far as rsync is concerned, so it would not benefit from the rsync protocol's delta-transfer speedup.
    – RJHunter
    Commented Jul 4, 2016 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .