LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-14-2008, 05:16 PM   #1
MarkA
LQ Newbie
 
Registered: Aug 2008
Posts: 3

Rep: Reputation: 0
Create Read-only directory in writeable filesystem (without using chmod)?


Hi,

I want to create a directory which is read-only but on a filesystem which is mounted as read-write, without using chmod. Does anyone have any ideas how to do this?

If you'd like more details about why this is needed, please see below:

I'm trying to create a rsync backup system similar to Mike Rubels, but while he requires the backup-server to mount the client machines directory to do the backup, I want it the other way around: the client machine mounts the backup servers directory and so it is the client that does the backup (when the user logs off from their machine).

But this setup means that the backup data on the server is writable by the client (it must be to make the backup in the first place), so I thought about using a nightly cronjob on the backup-server to move the backup to a read-only location. Then ideally the client machine would run rsync as:

rsync -a --delete --link-dest=/nfs_mount/backup_server/ro/backup.1/ /home/mark /nfs_mount/backup_server/backup.0/

The intent here is that the client compares files in the local /home/mark directory to those in a read-only directory /nfs_mount/backup_server/ro/backup.1, and if they are the same, makes hard-links under the writable directory /nfs_mount/backup_server/backup.0/home/mark/... to the read-only version of the file in backup.1, but for any files which are different, it will create a new file in the backup.0 location instead.

In order to create hard links to a file, the source file and the dest file must be on the same filesystem - so I can't use NFS readonly loopback mounting, or the rofs FUSE module etc... to store the read-only backup, as then I can't symlink to it from the writeable backup.0 directory. And I can't use chmod to remove write permissions from the files in backup.1 as if the files have different permissions, rsync will think the files are different and will copy all the files from /home/mark to backup.0, instead of using hard links from backup.0 to backup.1.

If anyone has any ideas how to solve this, I'd be keen to hear about them!

Cheers,

Mark

Last edited by MarkA; 08-14-2008 at 05:19 PM. Reason: fixing some typos!
 
Old 08-14-2008, 08:36 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,361

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The client needs to use/specify a read-only mount.
Is this NFS or SAMBA?
You could also make the files in qn
rw-r-----
so that the owner (server) can write, but but make the client only in the same group. This can be a perm setting, not just during backup process.
 
Old 08-15-2008, 03:38 AM   #3
MarkA
LQ Newbie
 
Registered: Aug 2008
Posts: 3

Original Poster
Rep: Reputation: 0
This will probably be SAMBA (as it has user-based authentication) rather than NFS, although the clients are a windows/linux mix.

Unfortunately the clients are untrusted, so I don't want to rely on them read-only mounting the backup server filesystem as maybe some windows worm on one of the clients will come along and remount all filesystems read-write, then proceed to trash that clients network backups.

Your perm solution is quite nice but I've just had a think about it and I'm not sure it will work - according to the rsync man page:

The files
must be identical in all preserved attributes (e.g. permissions,
possibly ownership) in order for the files to be linked
together.

so if the read-only copy of the files in the link-dest have different perms/ownership, then rsync will make new copies of the files in backup.0 rather than linking to the read-only files, for files that haven't changed on the client.

One option might be to go with your perms suggestion but modify the rsync code and add a new flag which will cause rsync to ignore differences in attributes when link-dest is specified.

Thanks for your reply!

Mark

Last edited by MarkA; 08-15-2008 at 04:02 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mounting filesystem writeable lord-fu *BSD 2 07-05-2005 09:59 AM
mkdir: cannot create directory `test': Read-only file system punt Linux - General 2 04-16-2005 09:58 PM
cannot create directory `/mnt/win_d/MP3': Read-only file system PapaJac Mandriva 11 03-04-2004 05:25 AM
cannot create directory `/mnt/win_d/MP3': Read-only file system PapaJac Mandriva 0 03-02-2004 04:09 PM
Filesystem should be Writeable! Why isn't it? lectraplayer Linux - Newbie 9 02-04-2004 02:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration