Move a instance between different places


This guide will show you how to move or copy your instance to a different project, region or cloud provider. 

Prerequisites:


To speed up this work, we recommend to use a temporary linux instance located at the same place as the source or target location. This make the transfer faster not needing to downloading to and uploading from your local machine.


Source location

Creating a snapshot


First step will be to create a snapshot of the instance. We recommend you to shutdown the instance while this is done to ensure data consistency. When snapshot is done, you can start you instance again.

We always recommend to use the ID or UUID of the server to make sure you are working with the correct one.


To get the the correct UUID of your server, you can see it in the control panel or list it in CLI with the following command:

openstack server list


Now you have to create a snapshot of your instance using the following command:

openstack server image create --name <new-image-name> --wait <uuid-of-instance>

After a short while you will get some output showing information on the new image, and also the state. It's probably queue and you need to wait until it's in active state before continue.


To see that actual status of the image and also the image_id, use the following command:

openstack image list | grep <new-image-name>

Image creation is completed when status is active.


Download your snapshot

Next step is to check which disk format the image has (normally raw or qcow2), and you can check this with the following command:

openstack image show <image_id> | grep disk_format


Now you have to download your snapshot to your local machine or created server used for this move. You apply the disk_format and image_id from the output of the 2 commands above.

openstack image save --file snapshot.<disk_format> <your_image_id>


When the file have been downloaded, you are done with the steps on the source side, and the following steps will be done on the target side.

Target Location


Load the rc-file for the target side. Instructions how to generate this can be found in the link to OpenStack client installation in the beginning of this guide.

source <target_openrc.sh>


Upload your snapshot

Start upload the file to the new location and use disk_format from above and also the name you want to give the image.

openstack image create --disk-format <disk_format> --file snapshot.<disk_format> <new_image_name>


Upload will take a while, and after getting your prompt back, you can check the status by using the following command.

openstack image list | grep <new_image_name>

When status is active, the uploadupload is done.


Create a new server.

Next step you need to do, is to create a new server from the uploaded image. This can be done either with CLI commands or via the control panel ( https://admin.citycloud.com ). The following steps are from then control panel.


Choosing Images and Private Images in the side panel, you will see the newly uploaded image.

Select Create a server shown by clicking the blue dot to the right on the row for the image you have uploaded.


Fill in the new name, size, network etc.

Remember that the volume needs to be at least the same size as the source server.



If you are using password to the server, you need to set the password for the new server by adding the following cloud-config rows under Advanced Options. If you miss this step you will not be able to login to the server and need to recreate it again.

#cloud-config
password: mypasswd
chpasswd: { expire: False }
ssh_pwauth: True


Conclusion

You now learned how you can download and upload instances using snapshots and launch the instance into a different region, project or OpenStack cloud provider by using the CLI tools.


After you have moved your instance and don't want to keep the old one, don't forget to remove it to save some cost.