questions about rsync's behavior

Special K

Diamond Member
Jun 18, 2000
7,098
0
76
I have read either conflicting information or could not find any information about the behavior of rsync under certain situations, and was hoping someone here could clarify a few points for me:



1. Let's say I have a 4 GB file that is monitored by rsync. If I rename this file but make no other changes to its content, will rsync recopy the entire 4 GB file again with the new name and then delete the original, or is it smart enough to just rename the existing file?



2. Let's say I have the same 4 GB file that is monitored by rsync. If I change one byte of this file AND rename it, will rsync recopy the entire 4 GB file again with the new name and delete the original, or is it smart enough to rename the existing file and change only the single byte?



3. Will rsync successfully copy files if they are in use when rsync is running? Does it capture all changes that have been committed to the file up to that point? I don't recall ever receiving an error from rsync claiming that a file was in use and could not be copied, yet the MS synctoy tool will not sync files that are currently in use. Why is this?



4. How could using the --whole-file option ever be faster than using the differential transfer option? I read the section in the rsync man page about this, but I don't get it. How could it ever be faster to send the entire file instead of just the changes?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
1. I'm 99% sure it'll copy/delete. I don't think it goes through the extra hoops of comparing every file's hash to every other file's hash, that would make a sync take exponentially longer the more files you have.

2. Copy/delete again I believe.

3. That depends, if it can open the file it'll copy it. On unix systems this usually works fine but on Windows some things get exclusively locked so another process can't even read the file.

4. I could see it being useful for the initial sync run, you know there's nothing in the destination so why waste time checksumming the source? The man page also says that it could be faster than the normal process if the speed of the source->destination is faster than that of the disks where spending time doing the checksumming would be a waste.
 

Special K

Diamond Member
Jun 18, 2000
7,098
0
76
Originally posted by: Nothinman

3. That depends, if it can open the file it'll copy it. On unix systems this usually works fine but on Windows some things get exclusively locked so another process can't even read the file.

When running rsync in windows via cygwin, rsync is still able to access and copy files that are open in other windows applications, yet synctoy cannot. Do you know why this is?

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I would guess that synctoy tries to open the files exclusively to ensure that nothing changes when it's copying them, if another process has the file open an exclusive open will fail.
 

Special K

Diamond Member
Jun 18, 2000
7,098
0
76
Originally posted by: Nothinman
I would guess that synctoy tries to open the files exclusively to ensure that nothing changes when it's copying them, if another process has the file open an exclusive open will fail.

You are correct - windows has a service called "Volume Shadow Copy" that enables one application to access a file for copying while it is in use by another application. Unfortunately, synctoy does not use this feature.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
VSS would be the better approach on Windows but even without it a process can open an already opened file as long as none of the openers have locked it for exclusive access.
 

Special K

Diamond Member
Jun 18, 2000
7,098
0
76
Originally posted by: Nothinman
VSS would be the better approach on Windows but even without it a process can open an already opened file as long as none of the openers have locked it for exclusive access.

I ran a little experiment - I was watching a .avi file while trying to back it up (along with the other files in the same directory) using rsync and synctoy. Rsync successfully backed up the file while I had it open in WMP, but synctoy gave an error about not being able to access the file, and did not back it up. Perhaps synctoy is trying to perform an exclusive open on the file, but rsync is not?