Best way to clone a live linux system
Solution 1
On the source machine:
dump -0 -f - / | ssh -c blowfish root@target_machine "cd /; restore -rf -"
This will dump the fs on your source machine, copy it over ssh and on the target machine it will restore it.
Of course you need to repeat this for every fs.
'blowfish' is there just to make it for faster compression and decompression.
Solution 2
VMWare Converter can do most modern OS's without shutting the server down, but as Dennis pointed out, we really need to know which OS you're running.
You'll end up with a virtual image of your server when you're done, rather than a raw disk image, but it's usually good enough for most work, depending on what you want to do with it once you've done it.
Solution 3
We generally do this:
- Boot the target virtual host off a cd (or netboot it)
- Prepare the filesystems on the virtual host (that is, prepare the disk(s), create the fileystems, and mount them).
- Rsync the files from the physical host to the virtual host
- Install the boot loader on the target host
This works great, as long as the data you're copying over is relatively stateless. If you're dealing, for example, with a database server, particularly one with a lot of activity, you will need to make sure that database is quiescent before you make the final cutover...so, something like this, after everything else is ready:
- Stop the database
- Perform a final rsync of the data
- Shut down the physical host
- Start up the virtual host
Solution 4
Which VM platform are you migrating to? VMWare has a converter for Linux. It'll convert a powered on machine.
Solution 5
Have a look at VMWare converter which I believe allows live system cloning.
Related videos on Youtube
drewrockshard
Updated on September 17, 2022Comments
-
drewrockshard almost 2 years
Does anybody know of a way to clone a live linux system? I have a live installation running a production site. Problem is, I'm needing to clone it (without bring it down), and then move it over (restore) to a virtual machine. I'm basically migrating from physical hardware to virtual hardware.
-
Ignacio Vazquez-Abrams over 13 yearsYou're going to have to bring it down regardless, to start it on the VM.
-
drewrockshard over 13 yearsPhysical hardware will be up -> cloning happens -> migrate to VM -> change address of URL -> done. I need specifics of best practice for cloning live systems.
-
Dennis Williamson over 13 yearsThe first step is to try to determine what operating system it's running.
-
-
drewrockshard over 13 yearsIn the end, it's in house, and VMWare based. The control panel is custom, so we'd basically be loading a live CD, and expanding/extracting/etc onto the VM. I'm not sure I can get access to the VM infrastructure to do the VMWare converter, but that all depends what is involved with this. To test however, I was going to try to migrate it over to a virtualbox vm just to see if this proof of concept worked at all.
-
drewrockshard over 13 yearsDo you think I could run the convertor on the physical machine and then "import" the converted vm into vmware (never used the convertor, so my terminology might be off).
-
Jason Berg over 13 yearsThe converter doesn't really work that way. Check out this link. It should show you the basics of how a conversion works vladan.fr/how-to-p2v-linux-into-vmware-esx-server
-
drewrockshard over 13 yearsWhat rsync command do you guys use?
-
drewrockshard over 13 yearsIs there a way to bypass the vmware infrastucture import so that I can keep the "converted" image locally on my system, or do I have to migrate to another infrastructure (no local ability)?
-
drewrockshard over 13 yearsThis one seemed to work the most efficient.
-
Str over 13 yearsIt's running on Fedora. FYI, I'm planning to image it for virtualization later, probably in Xen.
-
Str over 13 yearsFor virtualization purpose, if I'm not mistaken the image have to be in virtual image rather than raw disk image, right?
-
John Gardeniers over 13 years@Str, if you know what the OS is please edit your question to say so and use appropriate tags.
-
rjt over 9 yearsi can not get it to like the lower case r. i had part of this working by separating
-rf to -r -f
, but now restore: invalid option -- 'r' cat: invalid option -- 'r' -
Greg Glockner about 8 yearsNote that the VMWare Converter (currently) requires Windows, though it can migrate a Linux physical computer to a virtual machine.