1832413 Members
2957 Online
110042 Solutions
New Discussion

Re: Copying /home

 
Jeffrey F. Goldsmith
Super Advisor

Copying /home

I have a new HP-UX 11.23 server and wanted to know the best way of copying my users from the current server to the new server.

Can I restore the files from my weekend backup using Data Protector 5.5?

Do I need to create all of them over again?

Thanks for any and all help.
6 REPLIES 6
Raj D.
Honored Contributor

Re: Copying /home

Hi Jeffrey,

1. Copy the /etc/passwd file from the old server to newserver.

say copied as
/restore/pw.orig to newserver.



2. Create a script on the new server:

# cd /restore/pw.orig
# vi uadd.sc


cat /restore/pw.orig | while read line
do
USER=$(echo $line|awk '{FS=":";print $1}')
PASS=$(echo $line|awk '{FS=":";print $2}')
USERID=$(echo $line|awk '{FS=":";print $3}')
GID=$(echo $line|awk '{FS=":";print $4}')
INFO=$(echo $line|awk '{FS=":";print $5}')
HOME=$(echo $line|awk '{FS=":";print $6}')
SHELL=$(echo $line|awk '{FS=":";print $7}')
echo "Adding $USER"
useradd -u $USERID -g $GID -s $SHELL -c "$INFO" -o -m -k /etc/skel -d $HOME $USER
/usr/sam/lbin/usermod.sam -p`echo "$PASS"` $USER
done

Run the script and all the user will be created on the new server.


Username , UID , Homedir, shell, Group , password, and Gecos fileds everything will be created same as it was in old server.



3. Restore the home directory from old server to new server.


You are done.


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Copying /home

Hi (again) Jeffrey,

1.You can restore the /home directory using Protector 5.5. from old to new server.

2. Or if size is less than 8GB , you can use tar to copy it with tape.


3. Or you can do NFS export to /home of your old server , and mount and then copy it to /home on your new server.


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Sivakumar TS
Honored Contributor

Re: Copying /home


Dear Jeffrey,

#rcp -R -p host1:/ host2:/

the -p option coppies the files with PERMISSIONs info, UID,GID etc.

HtH,

Siva.

Nothing is Impossible !
Chan 007
Honored Contributor

Re: Copying /home

If this is a brandnew server and no users are using so far. Just copy the /etc/passwd, /etc/group file only if you are not having the Truster system.

Best option for copying is duing weekend NFS mount the old system on the new one and use
find and cpio command if you need only the less files.

If you use SAN best way is to VGexport with -s -p -m create a map file and Bind LUN to the new system and vgimport. All will be fine.

..007
Devender Khatana
Honored Contributor

Re: Copying /home

Hi,

Copying /etc/passwd and /etc/group will recreate the user accouts with same UID and GIDs. Also before logging in restore backup, which will create all the directory structure under /home. Allthough you need to create home directory for user not having it under /home.

It will also change root password also to be the same as of old server. So if you do not want it to be same then after restoring files before logging out change it using passwd command.

For backup of old server there are many ways. If you can export /home and mount it on new server then then suppose you mounted /home of old server at /homeold in new server. Then do this

#pwd
/homeold
#find ./ -name "*" -print|cpio -pdmv /home


HTH,
Devender
Impossible itself mentions "I m possible"
John Waller
Esteemed Contributor

Re: Copying /home

I have found that as long as you have not setup your original server as a trusted system you can copy the /etc/passwd and /etc/group to your new server. One warning is that depending on the O/S version of your original server it may not be an idea to rcp the entire passwd file. I believe HP-UX 11.23 has some extra users by default at the top of the file. I have found the bast way is to vipw on the original server, find where normal users start, + G to get the line number then :,$ w/tmp/passwd.users to write out to a seperate file. rcp that file to your new server then vipw again go to the end and :r /tmp/passwd.users to load them back to the new server.
To copy the /home directory, ensure the filesystem size is the same as the old server then
"remsh oldserver tar cf - /home | tar xvf -". You will need to make sure the /.rhost or /etc/hosts .equiv on you oldserver knows about your new machine.