Use snapshots to migrate instances¶
This guide can be used to migrate an instance between different clouds.
To use snapshots to migrate instances from OpenStack projects to clouds, complete these steps.
In the source project:
In the destination project:
Note
Some cloud providers allow only administrators to perform this task.
Create a snapshot of the instance¶
Shut down the source VM before you take the snapshot to ensure that all data is flushed to disk. If necessary, list the instances to view the instance name:
$ openstackserverlist +--------------------------------------+------------+--------+------------------+--------------------+-------------------------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+------------+--------+------------------+--------------------+-------------------------+ | d0d1b7d9-a6a5-41d3-96ab-07975aadd7fb | myInstance | ACTIVE | private=10.0.0.3 | ubuntu-16.04-amd64 | general.micro.tmp.linux | +--------------------------------------+------------+--------+------------------+--------------------+-------------------------+
Use the openstack server stop command to shut down the instance:
$ openstackserverstopmyInstance
Use the openstack server list command to confirm that the instance shows a
SHUTOFF
status:$ openstackserverlist +--------------------------------------+------------+---------+------------------+--------------------+-------------------------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+------------+---------+------------------+--------------------+-------------------------+ | d0d1b7d9-a6a5-41d3-96ab-07975aadd7fb | myInstance | SHUTOFF | private=10.0.0.3 | ubuntu-16.04-amd64 | general.micro.tmp.linux | +--------------------------------------+------------+---------+------------------+--------------------+-------------------------+
Use the openstack server image create command to take a snapshot:
$ openstackserverimagecreate--namemyInstanceSnapshotmyInstance
If snapshot operations routinely fail because the user token times out while uploading a large disk image, consider configuring nova to use service user tokens.
Use the openstack image list command to check the status until the status is
ACTIVE
:$ openstackimagelist +--------------------------------------+---------------------------+--------+ | ID | Name | Status | +--------------------------------------+---------------------------+--------+ | ab567a44-b670-4d22-8ead-80050dfcd280 | myInstanceSnapshot | active | +--------------------------------------+---------------------------+--------+
Download the snapshot as an image¶
Get the image ID:
$ openstackimagelist +--------------------------------------+---------------------------+--------+ | ID | Name | Status | +--------------------------------------+---------------------------+--------+ | ab567a44-b670-4d22-8ead-80050dfcd280 | myInstanceSnapshot | active | +--------------------------------------+---------------------------+--------+
Download the snapshot by using the image ID that was returned in the previous step:
$ openstackimagesave--filesnapshot.rawab567a44-b670-4d22-8ead-80050dfcd280
Note
The openstack image save command requires the image ID and cannot use the image name. Check there is sufficient space on the destination file system for the image file.
Make the image available to the new environment, either through HTTP or direct upload to a machine (
scp
).
Import the snapshot to the new environment¶
In the new project or cloud environment, import the snapshot:
$ openstackimagecreate--container-formatbare--disk-formatqcow2\ --filesnapshot.rawmyInstanceSnapshot
Boot a new instance from the snapshot¶
In the new project or cloud environment, use the snapshot to create the new instance:
$ openstackservercreate--flavorm1.tiny--imagemyInstanceSnapshotmyNewInstance