2

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 ?

jasonwryan
  • 73,126
huotg01
  • 41
  • Directory size as shown by ls is mostly meaningless. rsync doesn't pay attention to it. The reason why rsync wants to copy them is something else. For example, I see above a permissions discrepancy: drwxrwxrwx vs drwxr-xr-x. – Celada Feb 14 '15 at 00:40
  • By the way, rsync 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:41
  • Why do you say that ls reported sizes are meaningless? Rsync works by looking at the time stamp and at the size, no other points AFAIK. In fact I have no problem with the files syncing, even if they show the same discrepancy with the rights.option "a" ("archive")includes the recursive option. The problem seems to be related to the fact that directories have a size on the cifs mount, but not on the linux mount (the last being normal). rsync always see a difference in size (for the directories) and sync again the directories (but not the folders in the directories, which is correct). – huotg01 Feb 15 '15 at 12:52
  • Reported sizes OF DIRECTORIES are artifacts of the underlying filesystem implementations. They don't stand for something like the number of files inside the directory or the sum of the sizes of the files located inside the directory, or anything, really. Each individual filesystem can populate that field with basically anything is wants to. rsync 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:01
  • Thanks @Celada Even if reported sizes are artifacts of the underlying filesystem implementation, obviously Rsync does use the reported size (and time stamp) of the directories, otherwise I would not have the problem I have. Do you have another explanation ? – huotg01 Feb 15 '15 at 16:16
  • No, rsync 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
  • Thanks Celada. I have to apologize. It seems that the discrepancy in user rights were causing the problem...I finally found out a thread where it was suggested to add --no-p. I added the switch and it seems ok know. Sorry for that. Now I have a problem to understand the rsync include and exclude patterns (I'm used to very simple rsync commands). I opened a new thread: http://unix.stackexchange.com/questions/185168/unable-to-well-understand-rsync-with-include-and-exclude-patterns Thanks again. – huotg01 Feb 16 '15 at 16:59

0 Answers0