The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to block a user temporarily? winky AIX 3 06-19-2007 07:27 AM
fork: Resource temporarily unavailable - What can I check ? unclefab SUN Solaris 5 04-12-2007 11:22 AM
Temporarily disable effect of set -e in ksh ugeek Shell Programming and Scripting 1 03-28-2007 01:21 AM
Temporarily Disable User Account scotbuff HP-UX 4 01-26-2007 12:01 AM
temporarily stop cron services legato UNIX for Dummies Questions & Answers 1 12-31-2004 01:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: Apr 2008
Posts: 25
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Can is set permissions temporarily?

I want to do just what the title says. Here's why:

I am adapting a script that backups to a mount. In the script it has a catch where if the drive isn't RW then it unmounts and attempts to remount RW.

# attempt to remount the RW mount point as RW; else abort
$MOUNT -o remount,rw $MOUNT_DEVICE $SNAPSHOT_RW ;
if (( $? )); then
{
$ECHO "snapshot: could not remount $SNAPSHOT_RW readwrite";
exit;
}
fi;


I want to backup to another directory on the same drive, but i want that directories normal everyday permissions to be read only except for when i run the backup script. Is there a way to say "while this script runs apply these permissions to this directory? without simply chmoding at the front and backends of the script?

Suggestions are welcome.

Thanks,
Movomito
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 182
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by Movomito View Post
I want to backup to another directory on the same drive, but i want that directories normal everyday permissions to be read only except for when i run the backup script.
You're a bit hard to understand (among others your use of genitive is improper).

How I understand you:
i) you have a media which is mount ro
ii) you want to backup to it
iii) you therefore want to set only one dir of that drive to be writeable

That is not possible. In order to write to that device you need to mount it rw. Why don't you simply mount it rw?
Reply With Quote
  #3 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: Apr 2008
Posts: 25
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
sorry... perhaps i was unclear.

I want to backup one directory to another on the same drive. I don't want to use mount at all. The script that i am adapting uses mount in the section that i made in blue in the original post. The function of that section was to ensure that the device being used to backup to (in the script that i am adapting from) was mounted Read Write, and then at the end they unmount Read Only. I didn't describe this very well in my previous post.

But i am not trying to backup to an external device. Instead, i am simply backing up to another directory on the same file system (i am aware of the risks involved with this, it is on a Raid array using raid 5). The file system that i am backing up is huge and making it inaccessible to other users while the backup takes place is not really an option. So i would like to temporarily set the permissions to READ WRITE while the backup takes place, but when it is finished leave the backup directory as READ only. If i use chmod on the whole thing it will take forever, or at least that much longer. I would like to avoid having to do this. My hope, and reason for posting, is that there is a way to invoke permissions only during the actual backup process.

I hope this provides a little clarification.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 182
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quite likely you are going to do something that will hurt you in the future.

Maybe it's best not to use that script which does not seem to fit your task. Is it maybe easier to use e.g. rsync? (and that tool can also backup very efficiently over network, if desired. I do use it to (in place, incrementally) backup about 70 GB over a 1 mbit line)
[code]rsync /actual/data /backup/data --chmod=mode[/quote]

However:
That remount rw should not affect your running operations. A remount ro is likely to fail or hurt you - comment it out.

Quote:
The file system that i am backing up is huge and making it inaccessible to other users while the backup takes place is not really an option. So i would like to temporarily set the permissions to READ WRITE while the backup takes place
Which permissions? Those of the actual data!? Aren't they rw already?

Why do you want the backup'd data to be ro? First that's no real security, second it will prevent you from fast recovery in case of data loss.

If your script does not really care about permissions you can try to invoke umask (see man page) with some restrictive mask before running that script.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop boot: cannot open kernel/sparcv9/unix close_wait command copy/move folder in unix curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive grep unique inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp batch sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix forum unix forums unix interview questions unix mtime unix simulator unix.com vi tab size vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 12:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101