LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rsync minor glitch (https://www.linuxquestions.org/questions/linux-software-2/rsync-minor-glitch-945976/)

centguy 05-20-2012 04:07 AM

rsync minor glitch
 
I always use rsync to sync files on a portable drive and the internal drive.

Usually I create or download files to the portable drive and then
use rsync to help to sync the two drives.

Imagine I connect the portable drive to a linux system for the first time,
work on the data, and
then I sync the data, then disconnect it from the linux system since I need to shutdown the
machine.

Upon reboot, I connect the portable drive to linux again and then do rsync
just to make sure that no files need to synced.

However, I find that from time to time that the time stamp of the identical files on the portable drive and that on the internal drive
changes by just a little bit and this upsets rsync and trigger it to sync
it again.

Luckily, the time stamp will not change upon the second rysync.
Else rsync is going to work very hard as I accumulate more and more data
on the internal drive.

The following shows a typical change:

Quote:

% ls --full-time external-drive/A.pdf
-rwxr-xr-x 1 user user 1773350 2012-05-19 17:14:38.000000000 +0800 external-drive/A.pdf

% ls --full-time internal-drive/A.pdf
-rwxr-xr-x 1 user user 1773350 2012-05-19 17:14:39.000000000 +0800 internal-drive/A.pdf
The GUI diff program "meld" is able to put a little red do tell the diff.

Is there a way to solve this weird feature ?

pan64 05-20-2012 05:19 AM

probably you missed rsync has a feature to copy not only the file but its attributes also (like permissions, ownership and times).
to give more help we need to know how do you invoke rsync

rknichols 05-20-2012 09:14 AM

Quote:

Originally Posted by centguy (Post 4683066)
The following shows a typical change:

% ls --full-time external-drive/A.pdf
-rwxr-xr-x 1 user user 1773350 2012-05-19 17:14:38.000000000 +0800 external-drive/A.pdf

% ls --full-time internal-drive/A.pdf
-rwxr-xr-x 1 user user 1773350 2012-05-19 17:14:39.000000000 +0800 internal-drive/A.pdf

FAT-based file systems can only record time to a resolution of 2 seconds, and such a timestamp can never match one with an odd number of seconds. rsync has a "--modify-window=NUM" option to allow small mtime differences to be ignored. You can use "--modify-window=2" to get around the odd/even problem, but you might need to use "--modify-window=3602" to avoid issues with DST time changes.

centguy 05-21-2012 01:42 AM

rknichols:

Bingo. That's exactly what I was looking for.

For now I am using modify-window=1 because rysnc manuals says:

Quote:

--modify-window
When comparing two timestamps, rsync treats the timestamps as being equal if they
differ by no more than the modify-window value. This is normally 0 (for an exact
match), but you may find it useful to set this to a larger value in some situations.
In particular, when transferring to or from an MS Windows FAT filesystem (which rep-
resents times with a 2-second resolution), --modify-window=1 is useful (allowing
times to differ by up to 1 second).
Of course, --modify-window=2 will work too.

Thanks!


All times are GMT -5. The time now is 03:26 PM.