Openstack - Cinder Snapshot/Restore

## What's this?

Cinder volume の snapshot 作成、その snapshot から新規 Cinder volume 作成

## Initial state

#### Cinder volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 5175d6be-735c-411e-be21-85015c332d99 | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

## Take a snapshot of Cinder

#### Take a snapshot of Cinder

* Cinder command

````
    # cinder snapshot-create --display-name admin_vol01_ss admin_vol01
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |      created_at     |      2015-02-17T03:35:45.077828      |
    | display_description |                 None                 |
    |     display_name    |            admin_vol01_ss            |
    |          id         | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |        status       |               creating               |
    |      volume_id      | 5175d6be-735c-411e-be21-85015c332d99 |
    +---------------------+--------------------------------------+
````

* Nova command

````
    # nova volume-snapshot-create --display-name admin_vol01_ss admin_vol01
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |      created_at     |      2015-02-17T03:35:45.077828      |
    | display_description |                 None                 |
    |     display_name    |            admin_vol01_ss            |
    |          id         | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |        status       |               creating               |
    |      volume_id      | 5175d6be-735c-411e-be21-85015c332d99 |
    +---------------------+--------------------------------------+
````

#### Check the snapshot of Cinder

* Cinder command

````
    # cinder snapshot-list
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    |                  ID                  |              Volume ID               |   Status  |  Display Name  | Size |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 | 5175d6be-735c-411e-be21-85015c332d99 | available | admin_vol01_ss |  1   |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+

    # cinder snapshot-show admin_vol01_ss
    +--------------------------------------------+--------------------------------------+
    |                  Property                  |                Value                 |
    +--------------------------------------------+--------------------------------------+
    |                 created_at                 |      2015-02-17T03:35:45.000000      |
    |            display_description             |                 None                 |
    |                display_name                |            admin_vol01_ss            |
    |                     id                     | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    |                  metadata                  |                  {}                  |
    |  os-extended-snapshot-attributes:progress  |                 100%                 |
    | os-extended-snapshot-attributes:project_id |   a8085d1871f847bdb906ef4a28d1bd48   |
    |                    size                    |                  1                   |
    |                   status                   |              available               |
    |                 volume_id                  | 5175d6be-735c-411e-be21-85015c332d99 |
    +--------------------------------------------+--------------------------------------+
````

* Nova command

````
    # nova volume-snapshot-list
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    | ID                                   | Volume ID                            | Status    | Display Name   | Size |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 | 5175d6be-735c-411e-be21-85015c332d99 | available | admin_vol01_ss | 1    |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+

    # nova volume-snapshot-show admin_vol01_ss
    +--------------------------------------------+--------------------------------------+
    | Property                                   | Value                                |
    +--------------------------------------------+--------------------------------------+
    | created_at                                 | 2015-02-17T03:35:45.000000           |
    | display_description                        | -                                    |
    | display_name                               | admin_vol01_ss                       |
    | id                                         | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    | metadata                                   | {}                                   |
    | os-extended-snapshot-attributes:progress   | 100%                                 |
    | os-extended-snapshot-attributes:project_id | a8085d1871f847bdb906ef4a28d1bd48     |
    | size                                       | 1                                    |
    | status                                     | available                            |
    | volume_id                                  | 5175d6be-735c-411e-be21-85015c332d99 |
    +--------------------------------------------+--------------------------------------+
````



# Restore from a snapshot of Cinder (= Clone from the snapshot)

## Initial state

#### Cinder volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 5175d6be-735c-411e-be21-85015c332d99 | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

#### Cinder snapshot


    # cinder snapshot-list
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    |                  ID                  |              Volume ID               |   Status  |  Display Name  | Size |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+
    | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 | 5175d6be-735c-411e-be21-85015c332d99 | available | admin_vol01_ss |  1   |
    +--------------------------------------+--------------------------------------+-----------+----------------+------+

## Restore from a snapshot of cinder

#### Restore from a snapshot of cinder

    # cinder create --display-name admin_vol02_from_ss --snapshot-id 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 1
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                 nova                 |
    |       bootable      |                false                 |
    |      created_at     |      2015-02-17T03:44:26.871112      |
    | display_description |                 None                 |
    |     display_name    |         admin_vol02_from_ss          |
    |      encrypted      |                False                 |
    |          id         | 3559c032-6d8c-44fb-98e5-0f08d735b537 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |     snapshot_id     | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Check the cinder volume

    # cinder list
    +--------------------------------------+-----------+---------------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  |     Display Name    | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+---------------------+------+-------------+----------+-------------+
    | 3559c032-6d8c-44fb-98e5-0f08d735b537 | available | admin_vol02_from_ss |  1   |     None    |  false   |             |
    | 5175d6be-735c-411e-be21-85015c332d99 | available |     admin_vol01     |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+---------------------+------+-------------+----------+-------------+

    # cinder show admin_vol02_from_ss
    +--------------------------------+--------------------------------------+
    |            Property            |                Value                 |
    +--------------------------------+--------------------------------------+
    |          attachments           |                  []                  |
    |       availability_zone        |                 nova                 |
    |            bootable            |                false                 |
    |           created_at           |      2015-02-17T03:44:27.000000      |
    |      display_description       |                 None                 |
    |          display_name          |         admin_vol02_from_ss          |
    |           encrypted            |                False                 |
    |               id               | 3559c032-6d8c-44fb-98e5-0f08d735b537 |
    |            metadata            |                  {}                  |
    |     os-vol-host-attr:host      |                node-17               |
    | os-vol-mig-status-attr:migstat |                 None                 |
    | os-vol-mig-status-attr:name_id |                 None                 |
    |  os-vol-tenant-attr:tenant_id  |   a8085d1871f847bdb906ef4a28d1bd48   |
    |              size              |                  1                   |
    |          snapshot_id           | 375528d8-7d5e-40a4-a8d6-d4b5e9fad274 |
    |          source_volid          |                 None                 |
    |             status             |              available               |
    |          volume_type           |                 None                 |
    +--------------------------------+--------------------------------------+

## Environment

* Openstack : Juno
* Ceph : Firefly

## Reference

[Cinder Backup/Restore][link-01]
[Cinder Backup/Restore between AZ][link-02]
[Cinder Backup/Restore between Region][link-03]
[Cinder Snapshot/Restore][link-04]

[link-01]:http://qiita.com/idzzy/items/ac163d0ce7cc9f036031
[link-02]:http://qiita.com/idzzy/items/caaa83de00abe78095e2
[link-03]:http://qiita.com/idzzy/items/fef77c7853eb6f6b1479
[link-04]:http://qiita.com/idzzy/items/cfb568e83e2645e3f32e