[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

rsync, samba and read-only files

Posted on 2001-07-11
10
Medium Priority
?
800 Views
Last Modified: 2013-12-15
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?

0
Comment
Question by:sprinkmeier
  • 4
  • 4
  • 2
10 Comments
 
LVL 2

Author Comment

by:sprinkmeier
ID: 6275515
Did I mention I really need an answer?
0
 
LVL 14

Expert Comment

by:xberry
ID: 6276490
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 ' )  
0
 
LVL 40

Accepted Solution

by:
jlevie earned 600 total points
ID: 6279168
Yes, rsync works just like you theorized. And in fact that is the Unix way of doing things to ensure against data loss on a aborted data transfer. The behaviour of 2000 w/respect to read-only files is exactly as you describe. I don't have a 2000 server handy to check with, but I don't believe that 2000 will let you copy a file over a read-only file via a Samba mount of the repository.

The only credible solutions that I know of would be to:

1) Write a script that walks the file repository on each of the Samba mount points looking for read-only files. The script would need to keep a record of what files are readonly and change the mode to read-write. Then run the rsync and use a complimentary script to walk the repositories and re-set the files to read-only using the recorded information. It would be best to run this script on the 2000 boxes themselves so that the file permissions, as seen by windows clients, can be set back to exactly what they were before. Otherwise there's likely to be trouble with client access to the files.

2) Move the file storage to Linux boxes where you have full control of the file permissions.

3) Try to find a native 2000 solution to synchronizing the file repositories.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:sprinkmeier
ID: 6279252
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".
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6282167
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.
0
 
LVL 2

Author Comment

by:sprinkmeier
ID: 6284605
Did I mention I really need an answer?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6284708
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.
0
 
LVL 2

Author Comment

by:sprinkmeier
ID: 6284753
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)).
0
 
LVL 14

Expert Comment

by:xberry
ID: 6285186
to jlevie:

Thank you for getting over to ' Linux printing ' & helping ' sprinkmeier ' with his question.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6286390
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.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question