How to migrate your Cloud server using Snapshots

  Servers

Available methods

There are two methods you can use to migrate a server to a new location. In this tutorial we will use the ControlPanel and for the power-users we have an API witch can be accessed with cloudmonkey, a python program.

Required steps

Step 1: Create snapshot

Before creating a snapshot of your root volume, please shut down your instance. This will make sure the data will remain consistent.

To create a snapshot navigate to:

Products & Services >> Servers >> Instances >> My server >> Attached volumes

and select Snapshot from the menu.

The snapshot will then go into ‘Back-up’ state and will change into ‘Backed-up’ when finished.
To find the snapshot navigate to:

Products & Services >> Servers >> Snapshots

Step 2: Create template

In order for us to deploy a new Cloud server based on this snapshot we first have to create a template which we can later use to boot from.

To create a template navigate to:

Products & Services >> Servers >> Snapshots

and select Register template from the menu.

Fill in the name and description of this template. Please note that the template can be used to deploy multiple servers, so make sure to give it a good description.

 

Step 3: Deploy new server

When the template is done processing we can deploy a server based on it.

To deploy a new server navigate to:

Products & Services >> Servers >> Instances >> Deploy instance

When asked for the server-type please select Custom templates and choose the template you’ve just created.

You should now have a new Cloud server which is identical to the old one, with one small exception; new IP-addresses.

Possible problems and how to debug them

When migrating a server there are a few things that can go wrong which will result in the server not being able to boot. The best way to debug a Linux server is by entering the SingleUserMode or booting from a RescueImage

Here is a tutorial on how to edit the kernel parameters and enter Single User Mode.

A list of the most common problems you may encounter after migrating a server:

SElinux

If you are running a RHEV based OS like CentOS you might run into problems with SElinux and file labeling. To fix this add selinux=0 at the end of the kernel parameters. This will disable SElinux.

You might also need to relabel the system before booting. This can be done by adding an .autorelabel file on the root partition. Enter the system in SingleUserMode and execute this command: touch /.autorelabel.

Mountpoints

It is possible that the server had extra disks or network-points set up to automatically mount on boot. These can be found in the /etc/fstab file. When a disk cannot be found or a network-point cannot be accessed the server might not boot.

To fix this, enter the system with SingleUserMode and edit /etc/fstab. Here you can comment out or delete the faulty entry(s). Please make sure you relabel the system (see SElinux) and execute the command sync before rebooting.

Network

Please keep in mind that the server will get a new IP-address. Make sure your network configuration is set up for DHCP. The server needs this in order to get a new IP-address lease from the DHCP server.

It is also possible for the network interface name to change, for example: old: eth1 new: eth0.
If this occurs you must edit the network configuration and change the name of the interface to the correct one. To see what interfaces are available, please run this command ip l.
The best way to do this is by entering SingleUserMode and execute this command: sed -i '/old_interface/new_interface/g' /etc/network/interfaces.