Openstack - Cinder Backup/Restore between AZ

## What's this?

* Cinder volume の Backup を AZ1 に作成
* 新しい Cinder volume を別の AZ2 に作成し、そこへ Backup から Restore


## Initial state

#### Nova AZ

    # nova availability-zone-list | egrep -A 10 "^\| nova"
    | nova                     | available                              |
    | |- node-27 |                                        |
    | | |- nova-compute        | enabled :-) 2015-02-25T02:38:52.000000 |
    | |- node-28 |                                        |
    | | |- nova-compute        | enabled :-) 2015-02-25T02:38:45.000000 |
    | nova2                    | available                              |
    | |- node-31 |                                        |
    | | |- nova-compute        | enabled :-) 2015-02-25T02:38:53.000000 |
    +--------------------------+----------------------------------------+

#### Cinder AZ

    # cinder availability-zone-list
    +-------+-----------+
    |  Name |   Status  |
    +-------+-----------+
    |  nova | available |
    | nova2 | available |
    +-------+-----------+

#### Cinder volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01  |  1   |     None    |  false   |             |
    | 52a71ec9-57f2-4124-bb80-ba3d93e148e7 | available | admin_vol02  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show admin_vol01 | egrep "Property|availability_zone"
    |            Property            |                Value                 |
    |       availability_zone        |                 nova                 |


#### Cider Backup

    # cinder backup-list
    +----+-----------+--------+------+------+--------------+-----------+
    | ID | Volume ID | Status | Name | Size | Object Count | Container |
    +----+-----------+--------+------+------+--------------+-----------+
    +----+-----------+--------+------+------+--------------+-----------+

## Backup Cinder volume in AZ1

#### Take Cinder backup

    [node-27]# cinder backup-create --display-name admin_vol01_bkup admin_vol01
    +-----------+--------------------------------------+
    |  Property |                Value                 |
    +-----------+--------------------------------------+
    |     id    | 34706b5d-511a-4c5f-91ea-a62162fa44f6 |
    |    name   |           admin_vol01_bkup           |
    | volume_id | 37bc4c84-557c-4aed-abce-0994803aef61 |
    +-----------+--------------------------------------+

#### Check Cinder backup

    [node-27]# cinder backup-list
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+
    |                  ID                  |              Volume ID               |   Status  |       Name       | Size | Object Count | Container |
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+
    | 34706b5d-511a-4c5f-91ea-a62162fa44f6 | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01_bkup |  1   |     None     |  backups  |
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+


## Restore Cinder volume to AZ2 from the backup of AZ1

#### Create new Cinder volume in AZ2

    # cinder create --display-name admin_vol11 --availability-zone nova2 1
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                nova2                 |
    |       bootable      |                false                 |
    |      created_at     |      2015-02-25T04:55:45.992701      |
    | display_description |                 None                 |
    |     display_name    |             admin_vol11              |
    |      encrypted      |                False                 |
    |          id         | 5e608667-4489-4171-be96-14358c6f2836 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |     snapshot_id     |                 None                 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Check the Cinder volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01  |  1   |     None    |  false   |             |
    | 5e608667-4489-4171-be96-14358c6f2836 | available | admin_vol11  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show admin_vol11 | egrep "Property|availability_zone"
    |            Property            |                Value                 |
    |       availability_zone        |                nova2                 |


#### Restore to the Cinder volume of AZ2 from the backup of AZ1

    # cinder backup-restore --volume-id 5e608667-4489-4171-be96-14358c6f2836 34706b5d-511a-4c5f-91ea-a62162fa44f6

#### Check the Cinder volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01  |  1   |     None    |  false   |             |
    | 5e608667-4489-4171-be96-14358c6f2836 | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show 5e608667-4489-4171-be96-14358c6f2836 | egrep "Property|availability_zone"
    |            Property            |                Value                 |
    |       availability_zone        |                nova2                 |


#### Rename the Cinder volume

    # cinder rename 5e608667-4489-4171-be96-14358c6f2836 admin_vol11

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01  |  1   |     None    |  false   |             |
    | 5e608667-4489-4171-be96-14358c6f2836 | available | admin_vol11  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

## Delete backup

#### Initial state

    # cinder backup-list
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+
    |                  ID                  |              Volume ID               |   Status  |       Name       | Size | Object Count | Container |
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+
    | 34706b5d-511a-4c5f-91ea-a62162fa44f6 | 37bc4c84-557c-4aed-abce-0994803aef61 | available | admin_vol01_bkup |  1   |     None     |  backups  |
    +--------------------------------------+--------------------------------------+-----------+------------------+------+--------------+-----------+

#### Backup delete

    # cinder backup-delete 34706b5d-511a-4c5f-91ea-a62162fa44f6

#### Check

    # cinder backup-list
    +----+-----------+--------+------+------+--------------+-----------+
    | ID | Volume ID | Status | Name | Size | Object Count | Container |
    +----+-----------+--------+------+------+--------------+-----------+
    +----+-----------+--------+------+------+--------------+-----------+

## 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]

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