summaryrefslogtreecommitdiff
path: root/doc/source/admin/migrate-instance-with-snapshot.rst
blob: 65059679abb044c0c612335741a7cb7b74f94332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
==================================
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:

#. :ref:`Create_a_snapshot_of_the_instance`

#. :ref:`Download_the_snapshot_as_an_image`

In the destination project:

#. :ref:`Import_the_snapshot_to_the_new_environment`

#. :ref:`Boot_a_new_instance_from_the_snapshot`

.. note::

   Some cloud providers allow only administrators to perform this task.

.. _Create_a_snapshot_of_the_instance:

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:

   .. code-block:: console

      $ openstack server list
      +--------------------------------------+------------+--------+------------------+--------------------+-------------------------+
      | 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 :command:`openstack server stop` command to shut down the instance:

   .. code-block:: console

      $ openstack server stop myInstance

#. Use the :command:`openstack server list` command to confirm that the instance shows a
   ``SHUTOFF`` status:

   .. code-block:: console

      $ openstack server list
      +--------------------------------------+------------+---------+------------------+--------------------+-------------------------+
      | 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 :command:`openstack server image create` command to take a snapshot:

   .. code-block:: console

      $ openstack server image create --name myInstanceSnapshot myInstance

   If snapshot operations routinely fail because the user token times out
   while uploading a large disk image, consider configuring nova to use
   :ref:`service user tokens <user_token_timeout>`.

#. Use the :command:`openstack image list` command to check the status
   until the status is ``ACTIVE``:

   .. code-block:: console

      $ openstack image list
      +--------------------------------------+---------------------------+--------+
      | ID                                   | Name                      | Status |
      +--------------------------------------+---------------------------+--------+
      | ab567a44-b670-4d22-8ead-80050dfcd280 | myInstanceSnapshot        | active |
      +--------------------------------------+---------------------------+--------+


.. _Download_the_snapshot_as_an_image:

Download the snapshot as an image
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#. Get the image ID:

   .. code-block:: console

      $ openstack image list
      +--------------------------------------+---------------------------+--------+
      | 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:

   .. code-block:: console

      $ openstack image save --file snapshot.raw ab567a44-b670-4d22-8ead-80050dfcd280

   .. note::

      The :command:`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:

Import the snapshot to the new environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the new project or cloud environment, import the snapshot:

.. code-block:: console

   $ openstack image create --container-format bare --disk-format qcow2 \
     --file snapshot.raw myInstanceSnapshot

.. _Boot_a_new_instance_from_the_snapshot:

Boot a new instance from the snapshot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

.. code-block:: console

   $ openstack server create --flavor m1.tiny --image myInstanceSnapshot myNewInstance