Operating System - HP-UX
1827367 Members
5937 Online
109963 Solutions
New Discussion

Preserving filesystem ownerships

 
SOLVED
Go to solution
Chern Jian Leaw
Regular Advisor

Preserving filesystem ownerships

A user, i.e joe has a UNIX account on 2 remote sites, and his filesystems is transferred from site A to B by the super user. Transfer is done using rsync or ftp.

Once transfer is completed,user joe also wishes to access the filesystem on both sites, i.e. site A & site B. Site B would initially not contain the filesystems. Both remote sites have different NIS server. Hence the uid for all users is different between the sites. Also, his/her user name could different, or the same as in A.

Upon restoration, how do I write the a script to maintain the ownership of the user joe in site B, so that if joe(uid =1700) has file f1 in site A and also exist in site B as :
username = joebloggs
uid = 2100
file f1 does not exist for joebloggs in B

and another user in site B i.e alice(uid=1700) also has file f1; the ownership of file f1 would be preserved to the proper owner upon transferring to site B, regardless of the difference in uid and user names on both sites ?

Note:
User joe in site A would be accessing the same filesystems in B, but as a different user and different uid.

Thanks. Sorry that this question is really a long one.
3 REPLIES 3
John Carr_2
Honored Contributor
Solution

Re: Preserving filesystem ownerships

Hi
checkout the section which I answered in this thread and do exactly the same except for the tar.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x037b3f490f4ed61190020090279cd0f9,00.html

I change my false ID's to real ID's using the following command

find . -user joe -exec chown real_user_name {}\;

find . -group joes_group -exec chgrp real_group_name {} \;


if all the files are in one directory or under one directory you can do

chown -R joe:joegroup *




cheers
John.
David Burgess
Esteemed Contributor

Re: Preserving filesystem ownerships

Sounds complicated! What I'd do is look to sync the uid's across sites by editing the passwd files and changing the uid's to a higher number. Don't forget to update the NIS maps. Then chown -R on each filesystem that the user owns. Then using the automounter and nfs I'd share the filesystems to each server they log into. Also I'd make sure that the other users can access the filesystems using their group permissions. If the gid's are different then I'd set up a common group and link /etc/logingroup to /etc/group to ensure that even if the primary groups are different they can still gain access without having to issue the newgrp command.

HTH

Dave.
John Carr_2
Honored Contributor

Re: Preserving filesystem ownerships

Hi

Davids solutions is obviously a better one providing you have time and permission to implement it.

to go one step further would be to merge the two versions of NIS then chnage all files appropiatly and dispense with standard logins.

cheers
John