오픈스택 인스턴스를 백업 / 복구 하기 위해서는 아래 절차로 진행하여야 한다.
만약 인스턴스의 원본 이미지와 현재 인스턴스 상태가 동일하다면 굳이 해당 볼륨을 이미지로 받을 필요없이 원본 이미지를 받으면 된다. 하지만 보통 인스턴스의 데이터가 변경되어있는 경우가 대부분이기 때문에 위와 같은 절차를 진행하여야 한다.
(overcloud) [stack@director ~]$ openstack server list +--------------------------------------+---------+---------+--------------------+-------+--------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+---------+---------+--------------------+-------+--------+ | cda76fc8-d0ad-457b-9541-b118008aeafd | testvm1 | SHUTOFF | public=10.33.6.153 | | | +--------------------------------------+---------+---------+--------------------+-------+--------+ (overcloud) [stack@director ~]$ openstack volume list +--------------------------------------+------+--------+------+----------------------------------+ | ID | Name | Status | Size | Attached to | +--------------------------------------+------+--------+------+----------------------------------+ | 16fff669-a8c9-46ad-be4a-2fab5bf0277a | | in-use | 30 | Attached to testvm1 on /dev/vda | +--------------------------------------+------+--------+------+----------------------------------+ (overcloud) [stack@director ~]$ openstack volume snapshot list (overcloud) [stack@director ~]$ openstack volume snapshot create --volume 16fff669-a8c9-46ad-be4a-2fab5bf0277a --force testvm1-snap1 +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | created_at | 2024-11-22T02:24:40.626960 | | description | None | | id | 0179f1c9-2e43-4da5-ac54-e8642a2256f9 | | name | testvm1-snap1 | | properties | | | size | 30 | | status | creating | | updated_at | None | | volume_id | 16fff669-a8c9-46ad-be4a-2fab5bf0277a | +-------------+--------------------------------------+ (overcloud) [stack@director ~]$ openstack volume snapshot list +--------------------------------------+---------------+-------------+-----------+------+ | ID | Name | Description | Status | Size | +--------------------------------------+---------------+-------------+-----------+------+ | 0179f1c9-2e43-4da5-ac54-e8642a2256f9 | testvm1-snap1 | None | available | 30 | +--------------------------------------+---------------+-------------+-----------+------+
In-use
상태의 볼륨은 스냅샷 생성이 안되므로 --force
옵션을 추가하여 생성한다.
생성된 스냅샷으로 볼륨을 생성한다. 이미지를 만들기 위해서는 볼륨을 미리 만들어야 한다. 스냅샷을 바로 이미지로 등록할 수가 없다.
(overcloud) [stack@director ~]$ openstack volume create --snapshot 0179f1c9-2e43-4da5-ac54-e8642a2256f9 testvm1-vol1 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | true | | consistencygroup_id | None | | created_at | 2024-11-22T02:27:39.000000 | | description | None | | encrypted | False | | id | 46d7863c-c7c7-48ed-82dd-dbb91f1d6308 | | migration_status | None | | multiattach | False | | name | testvm1-vol1 | | properties | | | replication_status | None | | size | 30 | | snapshot_id | 0179f1c9-2e43-4da5-ac54-e8642a2256f9 | | source_volid | None | | status | creating | | type | tripleo | | updated_at | None | | user_id | d9eaca4fa12844afb8b701100a2a23b6 | +---------------------+--------------------------------------+ (overcloud) [stack@director ~]$ openstack volume list +--------------------------------------+--------------+-----------+------+----------------------------------+ | ID | Name | Status | Size | Attached to | +--------------------------------------+--------------+-----------+------+----------------------------------+ | 46d7863c-c7c7-48ed-82dd-dbb91f1d6308 | testvm1-vol1 | available | 30 | | | 16fff669-a8c9-46ad-be4a-2fab5bf0277a | | in-use | 30 | Attached to testvm1 on /dev/vda | +--------------------------------------+--------------+-----------+------+----------------------------------+
위에서 만들어진 볼륨을 이미지로 등록한다.
(overcloud) [stack@director ~]$ openstack image create --disk-format qcow2 --container-format bare --volume 46d7863c-c7c7-48ed-82dd-dbb91f1d6308 testvm1-image +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | container_format | bare | | disk_format | qcow2 | | display_description | None | | id | 46d7863c-c7c7-48ed-82dd-dbb91f1d6308 | | image_id | 136edb25-a8ba-409d-8bb3-fcd6026bcec8 | | image_name | testvm1-image | | protected | False | | size | 30 | | status | uploading | | updated_at | 2024-11-22T02:27:40.000000 | | visibility | shared | | volume_type | tripleo | +---------------------+--------------------------------------+ (overcloud) [stack@director ~]$ openstack image list +--------------------------------------+----------------------------------------+--------+ | ID | Name | Status | +--------------------------------------+----------------------------------------+--------+ | 6e4cab50-b174-4935-9447-4bd3db90f0a0 | RHEL8.4 | active | | 7ca8aea8-4d5f-47a0-b5b6-9d43957691e4 | RHEL8.9 | active | | fb8e8cee-693b-4aa2-b9a5-6f956939f874 | cirros | active | | 73917d69-2698-43f3-b2da-e03aa05e5dc5 | octavia-amphora-16.2-20211112.1.x86_64 | active | | 136edb25-a8ba-409d-8bb3-fcd6026bcec8 | testvm1-image | active | +--------------------------------------+----------------------------------------+--------+
만들어진 이미지를 파일로 저장한다.
(overcloud) [stack@director ~]$ openstack image save --file testvm1-image.qcow2 136edb25-a8ba-409d-8bb3-fcd6026bcec8 (overcloud) [stack@director ~]$ ll -sh total 953M 951M -rw-rw-r--. 1 stack stack 951M Nov 22 11:34 testvm1-image.qcow2