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