LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Restoring directory and subdirectory permissions/ownership (https://www.linuxquestions.org/questions/solaris-opensolaris-20/restoring-directory-and-subdirectory-permissions-ownership-4175499007/)

nativetongue03 03-21-2014 03:07 PM

Restoring directory and subdirectory permissions/ownership
 
Newbie here, again.

I made a mistake the day and set a directory ownership to chown -R user1:Other on directory Level1 thus making it
Code:

drwxr-xr-x  3 user1    other        512 Jul 11  2013 Level1
The original ownership was set to root:root
Code:

drwxr-xr-x  3 root    root        512 Jul 11  2013 Level1
but within that directory, about 3 directory levels down, there are multiple subdirs of files with various owners as seen below and I need to restore them.

Just to give you an example of what it SHOULD look like the information below is that from the second node of the cluster which still has it's correct permissions and ownerships set

ORIGINAL
Code:


NODE1:root@/var/Level1/Qmail/postfix$ ls -ltrh
total 28
drwx------  2 postfix  root        512 Jul 11  2013 corrupt
drwx------  2 postfix  root        512 Jul 11  2013 flush
drwx------  2 postfix  root        512 Jul 11  2013 hold
drwx-wx---  2 postfix  postfix      512 Jul 11  2013 maildrop
drwx------  2 postfix  root        512 Jul 11  2013 saved
drwx------  2 postfix  root        512 Jul 11  2013 trace
drwxr-xr-x  2 root    root        512 Jul 31  2013 pid
drwx------  18 postfix  root        512 Aug 23  2013 defer
drwx------  18 postfix  root        512 Aug 23  2013 deferred
drwx--x---  2 postfix  postfix      512 Mar 13 08:21 public
drwx------  2 postfix  root        512 Mar 13 08:21 private
drwx------  2 postfix  root        512 Mar 21 12:00 incoming
drwx------  2 postfix  root        512 Mar 21 12:00 bounce
drwx------  2 postfix  root        512 Mar 21 12:00 active

i want to know if there is any way to somehow export the directory and subdirectory ownerships/permissions from one node to duplicate it onto the other.

I've looked into using getfcal and setfcal but it doesnt seem to worth with multiple subdirectories.

Any assistance is appreciated.. Just trying to keep from having to set them all manually.

unSpawn 03-22-2014 08:51 AM

Quote:

Originally Posted by nativetongue03 (Post 5138867)
I made a mistake

Well as long as you learn from it...


Quote:

Originally Posted by nativetongue03 (Post 5138867)
export the directory and subdirectory ownerships/permissions from one node to duplicate it onto the other.

You might have to strip off a whole lot of options (always test with "--dry-run") but I think 'rsync' might do the trick. Else you could use 'find', print the required attributes and use that as a shell script on the victim side. This is GNU find:
Code:

find /var/spool \( -fprintf /tmp/ownership.txt 'chown %u.%g %p; chmod %m %p\n' \)


All times are GMT -5. The time now is 03:09 PM.