Solved

rsync, samba and read-only files

Posted on 2001-07-11
10
754 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
Comment Utility
Did I mention I really need an answer?
0
 
LVL 14

Expert Comment

by:xberry
Comment Utility
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 200 total points
Comment Utility
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
 
LVL 2

Author Comment

by:sprinkmeier
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Comment

by:sprinkmeier
Comment Utility
Did I mention I really need an answer?
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
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
Comment Utility
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
Comment Utility
to jlevie:

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

Expert Comment

by:jlevie
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now