Create Instance Snapshot and importing snapshot as image
A snapshot can be used as a backup or template for creating new instances.
Creating Snapshots from Instance
Web Interface
Go to Compute → Instance in Web Interface (https://openstack.stfc.ac.uk/)
Shut off your instance by clicking the drop-down menu on the right-hand side (in Actions column) and select SHUT OFF INSTANCE
Create a Snapshot by clicking the drop-down menu on the right-hand side (in Actions column) and select CREATE SNAPSHOT
Give it a name and click CREATE SNAPSHOT
Command-Line
Note
See Using OpenStack Command-line Interface on how to set-up the command line client.
Find the server ID (Instance) using the command below
$ openstack server list
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
| b5acb398-76b4-48fe-9b9a-d480636fdfd9 | test-rebuild | ACTIVE | Internal=172.16.101.195 | ubuntu-focal-20.04-gui | c3.small |
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
Shut down the instance using
$ openstack server stop <server-id>
#example
$ openstack server stop b5acb398-76b4-48fe-9b9a-d480636fdfd9
Confirm that the server is shut-off
$ openstack server list
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
| b5acb398-76b4-48fe-9b9a-d480636fdfd9 | test-rebuild | SHUTOFF | Internal=172.16.101.195 | ubuntu-focal-20.04-gui | c3.small |
+--------------------------------------+--------------------------+---------+----------------------------------------+---------------------------------------------------------+--------------+
Use
openstack server image create
to create a snapshot
$ openstack server image create --name test-snapshot b5acb398-76b4-48fe-9b9a-d480636fdfd9
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2021-12-03T12:37:40Z |
| file | /v2/images/2b9c6711-4dd8-4e5c-9edc-dd106b8319b5/file |
| id | 2b9c6711-4dd8-4e5c-9edc-dd106b8319b5 |
| min_disk | 20 |
| min_ram | 0 |
| name | test-snapshot |
| owner | fa0f417fb4b5462791e4320e317eb2d2 |
| properties | base_image_ref='90e1b77b-4192-46f1-8d9c-49fc36d9b54c', boot_roles='user', clean_attempts='2', description='Ubuntu-Focal-Gui', image_location='snapshot', image_state='available', image_type='snapshot', instance_uuid='b5acb398-76b4-48fe-9b9a-d480636fdfd9', locations='[]', os_distro='Ubuntu', os_hidden='False', os_variant='Gui', os_version='20.04-Focal' |
| protected | False |
| schema | /v2/schemas/image |
| status | queued |
| tags | |
| updated_at | 2021-12-03T12:37:40Z |
| visibility | private |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Check the image list
openstack image list
+--------------------------------------+----------------------------------------------------------+-------------+
| ID | Name | Status |
+--------------------------------------+----------------------------------------------------------+-------------+
| 2b9c6711-4dd8-4e5c-9edc-dd106b8319b5 | test-snapshot | active |
+--------------------------------------+----------------------------------------------------------+-------------+
Downloading snapshot
Check the image ID of the snapshot
$ openstack image list
+--------------------------------------+----------------------------------------------------------+-------------+
| ID | Name | Status |
+--------------------------------------+----------------------------------------------------------+-------------+
| 2b9c6711-4dd8-4e5c-9edc-dd106b8319b5 | test-snapshot | active |
+--------------------------------------+----------------------------------------------------------+-------------+
Run
openstack image save --file <file-name> <image-id>
#example
$ openstack image save --file snapshot.raw 0258526c-f523-4645-8a9d-f6980ad87864
Create new image from snapshot
Import snapshot to project
Note
See Using OpenStack Command-line Interface on how to set-up the command line client.
You must Downloading snapshot to local computer first.
Run
openstack image create --container-format bare --disk-format qcow2 --file <path-to-image-file> <name>
Example
$ openstack image create --container-format bare --disk-format qcow2 --file snapshot.raw test-snapshot
Booting From Image
Create a VM and selecting the image as the boot source
Example
Find the
image ID
$ openstack image list
+--------------------------------------+----------------------------------------------------------+-------------+
| ID | Name | Status |
+--------------------------------------+----------------------------------------------------------+-------------+
| 2b9c6711-4dd8-4e5c-9edc-dd106b8319b5 | test-snapshot | active |
+--------------------------------------+----------------------------------------------------------+-------------+
Create the VM
$ openstack server create --flavor c3.small --image 2b9c6711-4dd8-4e5c-9edc-dd106b8319b5 new-instance-from-snapshot