Operating System - HP-UX
1748124 Members
3264 Online
108758 Solutions
New Discussion юеВ

Re: Copy /etc/passwd, /etc/group to another server

 
SOLVED
Go to solution
d_bachelor01
Frequent Advisor

Copy /etc/passwd, /etc/group to another server

Hi Guys,

I need to copy the users from one server to another and create their home directories as well. Any specific instructions on how to do this? Can I just copy the /etc/passwd and /etc/group? How about the directories? Do I have to create them manually?

Thanks in advance!

-jef
9 REPLIES 9
Ramesh S
Esteemed Contributor
Kapil Jha
Honored Contributor

Re: Copy /etc/passwd, /etc/group to another server

Yes you can just copy passwd and group file.
You will have to make directories manually or copy the direcories to new system.
BR,
Kapil
I am in this small bowl, I wane see the real world......
d_bachelor01
Frequent Advisor

Re: Copy /etc/passwd, /etc/group to another server

any faster way to create those directories? thanks!
Kapil Jha
Honored Contributor

Re: Copy /etc/passwd, /etc/group to another server

make a tar or backup of /usr/users directory or wherever your home directories are and extract on target system.

Use -p to preserve permissions.

BR,
kapil
I am in this small bowl, I wane see the real world......
d_bachelor01
Frequent Advisor

Re: Copy /etc/passwd, /etc/group to another server

Hi Kapil

I tried to make a tar backup of my home directory. My current set up is that user directories are located on /home/user/user1....
/home/user/user2....
/home/user/user3....
.....

#tar cvf /tmp/home.tar /home/user/

however, my tar archive contains only the contents of each users home directories. I cannot see the subdirectories of the /home/user. Also, how can I preserve the permission of each folder and its subdirectories?

Thanks,
-jef
Peter Nikitka
Honored Contributor

Re: Copy /etc/passwd, /etc/group to another server

Hi,

when doing your backup
- I recommend NOT to use absolute pathnames.
- Create your tarfile at a place containing enough freespace (/tmp may be not big enough)
Use
cd /home
tar cvf /somewhere/backuser.tar user

You will see the progress of the backuped files on stdout.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
d_bachelor01
Frequent Advisor

Re: Copy /etc/passwd, /etc/group to another server

Hi Peter,

I dont have enough space on my /home/user directory. Anyway, I have more than 100 users.. I tried making an archive using tar but it seems that only the contents of the users home directories are copied. It is not divided according to "each" users own home directory. Any suggestions on how to make it done the fastest way? Also, I need to preserve the permissions including those in the sub-directories. It would really take some time if I would archive each home directories one by one.

Thanks!
-jef
Dennis Handly
Acclaimed Contributor
Solution

Re: Copy /etc/passwd, /etc/group to another server

>My current set up is that user directories are located on /home/user/user1....

(This seems like an extra level of indirection.)

>#tar cvf /tmp/home.tar /home/user/
>my tar archive contains only the contents of each user's home directories. I cannot see the subdirectories of the /home/user.

You have dumped the subdirectories of the /home/user, what do you think is missing?
I suppose if each home directory is automounted, tar may not see them all?
Yes, this happens to me. You'll need:
#tar cvf /tmp/home.tar /home/user/*

Of course if this is automounted, then there is no need to move them because they aren't there on that machine.

>how can I preserve the permission of each folder and its subdirectories?

As Kapil said, you can use -p. But that is the default for root, when you extract.

>Peter: I recommend NOT to use absolute pathnames.

You can always use pax(1) to rename it.

> cd /home; tar cvf /somewhere/backuser.tar user

You can combine these into:
tar cvf /somewhere/backuser.tar -C /home user

>I don't have enough space on my /home/user directory.

That's why Peter said: /somewhere

>but it seems that only the contents of the users home directories are copied. It is not divided according to "each" users own home directory.

This is contradictory. /home/user contains ALL user's home directories. tar should get all of them if you start at /home/user.
Unless some are symlinks??

You need to give an example of a file that isn't backed up. And see if that shows up with "ll /home/user".

>Any suggestions on how to make it done the fastest way?

Mount them over NFS?

>I need to preserve the permissions including those in the sub-directories.

Automatic for root.

>It would really take some time if I would archive each home directories one by one.

You need to explain to us why the command you or what Peter gave isn't working.
d_bachelor01
Frequent Advisor

Re: Copy /etc/passwd, /etc/group to another server

It's working now guys! Actually my command really works. The problem is with the transferring of the tar file to the other server. When I checked the size, its different from the original one. Thanks for all your help!!!

-jef