Server cloning is a useful tool, for example, for creating new web servers behind your load balancer. It is also useful if you just need to set up a server similar to what you already have, and wish to skip the hassle of configuring a new server from scratch.

Cloning a server performs the following three main operations:

  1. Create a new server with the same configurations as the base server.
  2. Create new storage disk that is a 1:1 copy of the base server’s storage.
  3. Attach the clone storage to the new server.

If the source server has several storage disks, all devices are copied and attached to the clone in order to create an exact copy of the original configuration.

Before cloning

Before cloning a server, you should check through your server to make sure everything is working as expected. For servers running CentOS 6.7 or older and Ubuntu 12.04 or older, you should rename the current MAC address reference file to avoid extra reboots.

sudo mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.old

The system will generate a new file again on the next reboot.

Other servers with an OSs different to those mentioned above, such as any newer Linux distribution or Windows Servers, do not need any special preparations for cloning.

Cloning a server

Note that the server being cloned must be shut down during the procedure.

To start cloning a server, log in to your UpCloud Control Panel. Open the server details by clicking the description of the server you wish to clone and simply click Clone server link under the Server Management in the General Settings tab.

This will open a new server deployment page with the details copied over from the original server. Check through the settings to make sure everything is in order.

Take care when selecting the Availability Zone for cloning. It is possible to clone the server to a new zone by changing the Availability Zone at the deployment settings. However, note that cloning between zones will be much slower than within a zone. This might not be viable for servers that cannot be left shut down for an extended period of time. If you wish to clone a server to a new zone, you can first create a temporary copy of the original within the same zone that can then be cloned to the new location.

Optionally you may change the Server Name and the Short Server Description as well as the server Configuration if needed before deployment. The only restriction is that the new server must have a storage disk at least the same size as the original server.

When you are done with the selections, click the Deploy server button to begin cloning.

After cloning

Cloning your cloud server means that the data is copied from one disk to another as is. All of the OS-level configurations will be exactly the same. This includes your usernames, passwords, and any SSH keys you might have added to your original server so that you may log in to the new cloned system just as to the original. However, once logged in, you might need to make some changes to the new server’s configuration like updating the hostname.

On Ubuntu and other Debian based distributions, open the hostname file for edit.

sudo nano /etc/hostname

With CentOS and other Red Hat variants, you’ll need to edit the HOSTNAME="example.upcloud.com" line.

sudo vi /etc/sysconfig/network

Replace the old hostname with a new one, save the file and exit.

If you cloned one of the older CentOS or Ubuntu distributions mentioned above and run into networking problems, try removing references to any old MAC addresses in the file /etc/udev/rules.d/70-persistent-net.rules and reboot to apply the changes.

Windows servers should work as is straight out of cloning. If you find issues with network connectivity, check that your network interfaces are turned on and working.