• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

linux - moving var etc and usr from one server to another

I have a server that lost the motherboard. So we brought up another server with the same OS - CentOS 5.4.

I tried to just tar and dump the etc usr and var dirs from the old drive onto the new system - and obviously theres a permission issue.

How can this be corrected?
0
totalimpact
Asked:
totalimpact
  • 4
  • 3
  • 2
  • +3
1 Solution
 
farzanjCommented:
Tar is a good way.  Other way could be rsync.  There certainly can be many other ways.

With tar do it this way.

tar --one-file-system Ppcvfz var.tgz /var --exclude *tmp* --exclude *tar


Then you can dump it by simply

tar Ppxvfz var.tgz
0
 
farzanjCommented:
So:

P keep track of the complete paths
p keeps all the permissions intact.

With --exclude, you can exclude patterns that you want to skip, and don't want to be included into your tar

Other options to consider:
--acls : if you want to tar acls also
--selinux : if you happen to have SELinux context
--xattrs :  If you want to keep extended file attributes
0
 
wesly_chenCommented:
1. Backup /etc, and /var before you overwite them.

2. "root" account have all the permission.

3. Copy the tar files on /.
Boot into single user mode (as root)
# init 1
------- Backup
# cd /
# mkdir /etc_backup /var_backup
# tar cvf - /etc | tar -xf - --strip-components 1 -C /etc_backup
# tar cvf - /var | tar -xf - --strip-components 1 -C /var_backup
------- Untar the one from other server
# cd /
# tar xf etc.tar
# tar xf var.tar
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Joseph GanSystem AdminCommented:
You don't need to copy all /etc, /usr and /var, they are all belong to OS. You can copy only some logfiles and configuration files, they are under /usr/local and /var/log and others which users and administrator created, such as /home etc.
0
 
arnoldCommented:
Why weren't the old drives moved to the new system which should have booted with out a problem other than the network interface may have changed in the event the networking card  but that is easily correctable?

In your approach you decided to install the system anew so I am not sure what is it you are trying to achieve by copying these directories? copying /etc with the start scripts, does not install the software they should start.  The /var partition has broad scope for use, so not sure what you were trying to copy there /var/mail?




0
 
totalimpactAuthor Commented:
unfortunately the system is 1000 miles away, and the local tech is not too skilled, so i am left with this mess.

I dont really have time to muddle through usr, as there are actually other locations that I need besides /usr/local that would take some time to track down.

besides that - the old hard drive works at the moment, but i dont want to push it - its mirror died a couple months ago.

The problem I am having is the UID attributes dont match - so binaries dont have permission to run (chown doesnt fix this).

farzanj: do those switches take care of this UID issue?

i am thinking to boot from a cd and get ssh up to try dd.
0
 
farzanjCommented:
My tar command would keep the user/group ownership.  By "UID don't match" do you mean the UID numbers on source system represent a different user than on the target system?

If you can still access the system, log on to it, become root, try mounting some (ANY) NFS share and make TARs on it.  Just works perfectly, keeps user/group ownership and permissions along with full paths, so you don't need to use -C option to specify the target location (you certainly can, if you wanted to).
0
 
mrjoltcolaCommented:
You should check /etc/passwd and /etc/group to determine differences and fix those or just synch up the /etc/passwd, group and secret files before the restore.
0
 
arnoldCommented:
Do you have a backup of the old system that you can restore on the new?
There are many unknowns i.e. application/services that were running on the old server and need to be running on the new server.
It is clear that the old nor the new server are centrally managed through a directory (NIS/LDAP).

Are you looking to synchronize the UID/GID from the old server on the new server by using a script to process the old servers passwd/shadow and create the users with the matching uid/gid/password on the new server?

Was the new server prebuilt just for this type of sitation? i.e. a spare?

0
 
totalimpactAuthor Commented:
i did this procedure correct before asking the question, but my source disk had a corrupt folder, all the files were in the folder, and ls -l showed correct owner ship, but after logging in as the owner of those files - ls -l showed ???? as the owner, this only happened on a single folder holding several crucial binaries.
0
 
farzanjCommented:
Make sure your crucial folder has execute permissions.  ls -l typically gives ??? when there is no execute permission on the folder.
0
 
totalimpactAuthor Commented:
it was 775, and showed this when running ls -l as root - it would say for instance the owner is apache, but if I su to apache and run ls -l, owner=?????? and permissions=???????
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now