From a Linux box, I recently mounted a Windows share using CIFS.
The intent was to "locally" use rsync
to backup my Windows machine.
The command line used to mount the Windows drive is something like:
mount \\192.168.1.74\share /cifs1 -t cifs -o noserverino,iocharset=utf8,ro
Please also note that the drive attached to the Linux box is formatted NTFS.
When doing a sample backup, rsync
was always re-copying the directories (names), but not the files. After looking more closely at the ls -lh
output at both ends, I noticed that on the Linux side the size of the directory level is always 0:
TTT-Admin@1080-Router:/tmp/mnt/RT-1080/tmp# ls -lh
drwxrwxrwx 1 TTT-Admi root 0 Feb 8 12:14 DeltaCopy
but the size of the directory level on the CIFS side was always different from 0:
TTT-Admin@1080-Router:/cifs1/temp/Rsync-Packages# ls -lh
drwxr-xr-x 1 TTT-Admi root 8.0K Feb 8 12:14 DeltaCopy
This difference explains why rsync
was always recopying directories, but not recopying the folders (which was correct, folder sizes and time stamps being the same on both ends).
The rsync
command is:
rsync -av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/rsync
-av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/
Is a directory supposed to "have a size" or not? What should I do to solve this discrepancy ?
ls
is mostly meaningless.rsync
doesn't pay attention to it. The reason whyrsync
wants to copy them is something else. For example, I see above a permissions discrepancy:drwxrwxrwx
vsdrwxr-xr-x
. – Celada Feb 14 '15 at 00:40rsync
works MUCH better if you run it on both sides of a network connection rather than locally on a remote-mounted filesystem. – Celada Feb 14 '15 at 00:41rsync
does indeed use size and timestamp as a shortcut for deciding whether or not regular files match between source and target, but not directories. – Celada Feb 15 '15 at 13:01rsync
does not use the size of directories in deciding whether or not to transfer them. It wouldn't make any sense to do so for the reason I stated, but just to make double sure, I just tested it. It does not. I rsynced 2 directories between two systems, one using ext4 and the other using xfs. Because of the different filesystems, the directory sizes are reported different even if they have the same contents.rsync
, quite correctly, does not re-transfer them every time. – Celada Feb 16 '15 at 00:57