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.
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.
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.
Which VM platform are you migrating to? VMWare has a converter for Linux. It'll convert a powered on machine.
Have a look at VMWare converter which I believe allows live system cloning.
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
Look at VMware Converter (it's free if you have vCenter) or Plate Spin (one of their products is a converter).
Plate Spin will do a machine live, with minimal downtime to cut over.
With VMware converter, it'll do a live machine (if there's a database it might be out of sync) just don't have it boot the VM when it is finished. Then disconnect the vNIC and then boot the machine, log in via the console and change the IPs, etc. Then reconnect the vNIC.
Its impossible to get a consistent snapshot without stopping all operations which may change the state of the system.
Unless the application has been explicitly designed to accomodate this kind of operation (i.e. all processing handled via queueable messages) it is be impossible to get a consistent snapshot without bringing the system down (or at least disabling the transactional component).
However it is possible to reduce the time window for snap-shotting the system significantly (e.g. by removing a mirror from a RAID set then remounting it elsewhere). And the shorter the time it takes to generate the snapshot, the less likely that transactions will span the operation.
And most filesystems / DBS will support some sort of journalling which should allow most broken operations to be either recovered or rolled back.