Solved

rsync, samba and read-only files

Posted on 2001-07-11
10
764 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Zimbra on Amazon Linux help 7 112
SSL/TLS - openssl troubleshooting 3 61
simple bash script needed to unpack tar.gz 4 28
check the file dates in unix 14 28
Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

749 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