How to clone a linux live server with no stopping it?
You can always just do a tar.gz. I have done this to clone systems. Obviously, you need to create partitions, format, and mount before untar on the destination system. Also, you will need to install grub after, and of course root privileges on the source machine.
I usually list each partition separately and use --one-file-system
. For example, imagine you have a system with /
, /boot
, /usr
, /var
and /tmp
different partitions. You could do a tarball of the whole system like this:
tar --one-file-system -cjpf backup.tar.bz2 / /boot /usr /var"
Also /sys
, /dev
, /proc
, /tmp
would need to be created in the destination system. /dev
could be included in the tarball, it doesn't harm. Here you are copying also /var/tmp
just because it is not a separate partition from /var
, you could always use --exclude
if you don't want to copy it. Usually I don't care if it's not too big.
Other than that, that would copy a running system which can contain certain inconsistencies (for example running databases). The effect when starting the copy for the first time will be as if the machine had been powered off abruptly.