How do I clone an unmanaged Linux system?

Post Reply
User avatar
Edge100x
Founder
Founder
Posts: 12945
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

How do I clone an unmanaged Linux system?

Post by Edge100x »

If you wish to clone (copy) one Linux unmanaged machine to another, try the following.

1. Create the new unmanaged machine via your "Server control" page, making sure to use the same OS.
2. Connect to the new machine via SSH.
3. Run a command like the following on the new machine:

Code: Select all

rsync -aHvz --sparse your.old.machine.ip:/ / \
 --exclude=/proc \
 --exclude=/sys \
 --exclude=/mnt \
 --exclude=/dev \
 --exclude=/tmp \
 --exclude=/swap.img \
 --exclude=/etc/udev/rules.d/70-persistent-net.rules \
 --exclude=/etc/conf.d/net \
 --exclude=/etc/network/interfaces \
 --exclude=/etc/sysconfig/network-scripts \
 --exclude=/etc/sysconfig/network \
 --exclude=/etc/conf.d/hostname \
 --exclude=/etc/hostname \
 --exclude=/etc/fstab \
 --exclude=/etc/resolv.conf \
 --exclude=/etc/localtime \
 --exclude=/var/log \
 --exclude=/var/run \
 --exclude=/var/spool \
 --exclude=/var/tmp \
 --delete
This command should work for Gentoo, Ubuntu, or CentOS. It will copy over your entire system, but keep the hostname, time zone, and network configuration of the new machine intact. The only catch is that it may not work in some cases due to hard drive UUIDs being used -- you may have to exclude /boot and related files in that case.

The process should be relatively quick, since only changed files will be transferred. To conserve bandwidth, files will be compressed as they are transferred.
Post Reply