4

I've read that rsync cannot detect moved folders, and simply delete and recopy them into the new folder structure.

Since the only change I did to my master copy is the simple introduction of a top folder to contain my original files, i.e.:

folder1
folder2
folder3

into

top\folder1
top\folder2
top\folder3

I was wondering if I could just do the same manually in my backup copy, fix the modification times of both top folders somehow, so that succeeding calls to rsync would run normally.

Will this work? If so, how? If not, what is the recommended way to solve this problem? Or should I be running rsync with different parameters in the first place? (instead of rsync -a --delete /mnt/SRC /mnt/DEST which I'm currently using)

The directories are pretty large and so I'd like to avoid unnecessary recopying as much as possible.

3 Answers3

2

Yes, you can do the move in the backup copy manually, and then run rsync. You shouldn't need to alter the modification times; just let rsync do that.

A rename like that is difficult to detect automatically, so duplicating it manually is the usual solution.

cjm
  • 27,160
0

If you movelly, you should not need to manually update the modification times of the files as well.

If you don't specifically care about mirroring the new directory structure, and just want the files, you could also rsync --(options) /mnt/SRC/newdir/ /mnt/DEST. Note the extra slash on the SRC side or you will end up copying everything anew.

0

The solution suggested here did the trick:

rsync -vrt --size-only /src/ /dest/

The --size-only option causes rsync to ignore timestamps, while -t (preserve modification times) causes rsync to fix any discrepant modification times in the destination copy.

  • 1
    That probably wasn't necessary in this case. Only the directories' timestamps would be different, and comparing two directories is not a very expensive operation for rsync. The timestamps on the files would all still match. – cjm Oct 07 '13 at 20:32
  • This won't have rsync look in different places for candidate duplicates. – Tom Hale Aug 02 '19 at 07:36