[CentOS] Help! i want to clone my Centos machine to another box..

Les Mikesell lesmikesell at gmail.com
Thu Oct 22 13:30:29 UTC 2009


RoLaNd RoLaNd wrote:
> 
> thanks for your prompt reply..
> i was leaving that option as a last resort...
> the problem is that this machine is a production machine
> so if i rsync, i need to turn off the services in order to copy files or 
> else ill have permission denied errors...
> 
> any other way?

It is rare for files to be locked on Linux when in use, so you probably won't 
get permission denied errors.  However, if files are changing while you copy 
them you will get a bad copy.  One approach is to do one rsync with the machine 
running normally, then repeat with most of the services stopped.  The 2nd pass 
will go very quickly since it only has to copy the changed files.

> i;ll start the proccess of creating a fresh instalation today though i 
> dunno how to do the followign:
> 
> 1. backing up my mysql databases  is it enough to cp /var/lib/mysql and 
> /user/lib/mysql or i have to export them? and if thats the case how can 
> i export?

If mysql isn't running and you are copying to the same type of machine (32/64 
bit) you can copy the files directly.  Otherwise, msqldump is the way to export 
(and what you should be using regularly for backups).

> 2. anyway of copying user permissions and passwords? or i have to create 
> them all over again ?

You'll have to work through the files in /etc by hand, since some relate to the 
hardware and some to the configured software.  If all the installed software is 
the same on the new system you can probably just copy /etc/passwd, /etc/shadow, 
/etc/group, and /etc/gshadow but a safer approach is to keep the uid's below 500 
from the new system and edit in the higher ones from the old.

I'd either copy the old /etc tree to some other location on the new system so 
you can diff and pick out the useful parts or change the old system's name/IP so 
you can access it until the new one is completely working.

I've always thought that linux distos badly needed a 're-install' function to 
adapt a clone/backup copy to new hardware. Most of the knowledge of what has to 
change is buried in anaconda - although you have a fair chance of making it work 
if you boot a rescue CD and rebuild the initrd with the modules that are set up 
when you do an install on that machine.

--
   Les Mikesell
    lesmikesell at gmail.com





More information about the CentOS mailing list