Link to home
Start Free TrialLog in
Avatar of sprinkmeier
sprinkmeier

asked on

rsync, samba and read-only files

I'm using rsync to keep two samba-mounted directory trees (serverd by Windoze 2000 server) synchronised.

rsync seems to work by creating a new version of changed files, then renaming it over the top of the old version.

Windoze does not allow renaming over the top of read-only files, so this request (via SAMBA) fails.

currently I "chmod --rec 777" before the rsync, really ugly but it works (mostly... slows things down, some side-effects). "find"-ing R/O files and only mangling those is an improvement, but no answer.

moving the files to the linux server is currently not an option (darn!!!).

Any ideas on how to get around this?

Avatar of sprinkmeier
sprinkmeier

ASKER

Did I mention I really need an answer?
Please hold on, I try to find an SAMBA expert for you quick.

(Please notify that this section is ' Linux printing '. Your concern rather falls within ' Linux administration ' or  ' Linux networking ' )  
ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1) sort of implemented that now. I parse /var/log/messages for rsync errors and try to fix them (i.e. chmod 777 and let tomorrow's SYNC do it's thing)

2) I'd _LOVE_ to do that. politics.......

3) haven't found anything that doesn't swamp the WAN.

there's always

4) patch the rsync code (gotta love GPL!!)

I was hoping there was a samba option or something which I've missed.

Thanks anyway, still not sure how I ended up in "printing".
Rather than grep the logs for things that failed I'd suggest taking premeptive action. If you did:

# find /path-to/smb1 ! -perm +200 >/tmp/wrong-mode
# find /path-to/smb2 ! -perm +200 >>/tmp/wrong-mode
# cat wrong-mode | xargs -i{} chmod u+w "{}"
...do the rsync here...
# cat wrong-mode | xargs -i{} chmod u-w "{}"
# rm /tmp/wrong-mode

The permissions would be correct while the rsync is being done and they'd be put back to what they were before after the rsync is complete. As far as client access to the files is concerned that seems a bit safer to me as compared to changing the file mode to 777.
Did I mention I really need an answer?
There's not anything other than changing the file modes as you've been doing that is going to help. The problem is at the w2k side as it is what prevents you from overwriting a read-only file. When manipulating any shared resource, be it a w2k share or an NFS export, it is the server that owns the files that determines what operations are allowed. In this case Samba, which mounts the w2k share, is prevented from overwriting the read-only files by w2k. So there isn't anything that can be done about it as far as Samba is concerned. All you can do from the Linux (client side) is to change the permissions of the read-only files while doing the rsync. That, of course, assumes that the Samba server has the necessary privs w/respect to the w2k servers.
I'm not sure how the second
"Did I mention I really need an answer?"
got posted.

I'm actually happy with the answer.

As for "there isn't anything you can do", I thought it should be possible to patch RSCYNC/SAMBA to chmod the original before trying to rename the copy.

RSYNC isn't the only program to do this renaming thing, so adding this supprot to SAMBA might solve other peoples problems too (actually, I thought it maybe already was an option (just one I couldn't find)).
to jlevie:

Thank you for getting over to ' Linux printing ' & helping ' sprinkmeier ' with his question.
Well you could change the rsync code, but I wouldn't recommend a change in Samba as that would break the file protection mechanism when Samba is being used for ordinary uses. In that case you probably don't want to blindly override the read-only status of a file or directory to help protect against "stupid mistakes". It would seem to me that not being able to overwrite a read-only file is the expected behaviour. And assuming the user has the appropriate rights the normal thing to do, if you really mean to overwrite a read-only file, is to change the permissions than then execute the file copy/move/delete.