openstack-manuals/doc/user-guide/source/cli-use-snapshots-to-migrate-instances.rst
qiaomin 80185e55c3 [user-guide] Use 'openstack image list' to replace 'nova image-list'
The command 'nova image-list' is deprecated and will be removed after
Nova 15.0.0 is released, so this patch use 'openstack image list' to
replace it in user guide for cleanup.

Change-Id: I121ad944e10538ab41c736c50337141893681129
2016-10-19 09:33:33 +00:00

4.7 KiB

Use snapshots to migrate instances

To use snapshots to migrate instances from OpenStack projects to clouds, complete these steps.

In the source project:

  1. Create_a_snapshot_of_the_instance
  2. Download_the_snapshot_as_an_image

In the destination project:

  1. Import_the_snapshot_to_the_new_environment
  2. Boot_a_new_instance_from_the_snapshot

Note

Some cloud providers allow only administrators to perform this task.

Create a snapshot of the instance

  1. 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:

    $ nova list
    +--------------------------------------+------------+--------+------------------------------+
    | ID                                   | Name       | Status | Networks                     |
    +--------------------------------------+------------+--------+------------------------------+
    | c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | ACTIVE | private=10.0.0.3             |
    +--------------------------------------+------------+--------+------------------------------+
  2. Use the nova stop command to shut down the instance:

    $ nova stop myInstance
  3. Use the nova list command to confirm that the instance shows a SHUTOFF status:

    $ nova list
    +--------------------------------------+------------+---------+------------------+
    | ID                                   | Name       | Status  | Networks         |
    +--------------------------------------+------------+---------+------------------+
    | c41f3074-c82a-4837-8673-fa7e9fea7e11 | myInstance | SHUTOFF | private=10.0.0.3 |
    +--------------------------------------+------------+---------+------------------+
  4. Use the nova image-create command to take a snapshot:

    $ nova image-create --poll myInstance myInstanceSnapshot
    Instance snapshotting... 50% complete
  5. Use the openstack image list command to check the status until the status is active:

    $ openstack image list
    +--------------------------------------+---------------------------------+--------+
    | ID                                   | Name                            | Status |
    +--------------------------------------+---------------------------------+--------+
    | 657ebb01-6fae-47dc-986a-e49c4dd8c433 | cirros-0.3.2-x86_64-uec         | active |
    | 72074c6d-bf52-4a56-a61c-02a17bf3819b | cirros-0.3.2-x86_64-uec-kernel  | active |
    | 3c5e5f06-637b-413e-90f6-ca7ed015ec9e | cirros-0.3.2-x86_64-uec-ramdisk | active |
    | f30b204e-1ce6-40e7-b8d9-b353d4d84e7d | myInstanceSnapshot              | active |
    +--------------------------------------+---------------------------------+--------+

Download the snapshot as an image

  1. Get the image ID:

    $ openstack image list
    +-------------------+-------------------+--------+
    | ID                | Name              | Status |
    +-------------------+-------------------+--------+
    | f30b204e-1ce6...  | myInstanceSnapshot| active |
    +-------------------+-------------------+--------+
  2. Download the snapshot by using the image ID that was returned in the previous step:

    $ glance image-download --file snapshot.raw f30b204e-1ce6-40e7-b8d9-b353d4d84e7d

    Note

    The glance image-download 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.

  3. 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:

$ glance --os-image-api-version 1 image-create \
  --container-format bare --disk-format qcow2 --copy-from IMAGE_URL

Boot a new instance from the snapshot

In the new project or cloud environment, use the snapshot to create the new instance:

$ nova boot --flavor m1.tiny --image myInstanceSnapshot myNewInstance