Restore in Openstack VM
Restore volumes attached to a previous backup or a specific volume by running the /opt/bacula/bin/openstack-vm-execute-restore
procedure with relevant parameters.
The /opt/bacula/bin/openstack-vm-execute-restore
program available in the OpenStack server must be used for restores. This program can be added to a RunScript block of
an Admin job, and this Admin job can be triggered from bconsole or BWeb.
The /opt/bacula/bin/openstack-vm-execute-restore
program can be used with a few parameters.
Parameters
-b <backup_id>
- ID of a specific volume backup to restore.-c <admin-openrc>
- Path to modified admin-openrc.sh Default value is/opt/bacula/etc/admin-openrc.sh
.-n <backup_name>
- If this parameter is set, the volume with this name will be restored.-t <tools>
- Path to Openstack procedure. Default value is/opt/bacula/bin/
.-v <instance_id>
- ID of the instance to restore.-w <waitingTime>
- Waiting time in seconds between two completion check. Default value is5
.-h
- Display help.
Examples
Restore Volumes from an Instance Using openstack-vm-execute-restore
This example explain how to restore all the volumes, or a specific volume, from an existent
instance, using the /opt/bacula/bin/openstack-vm-execute-restore
procedure in the
OpenStack node.
Note
To get the ID of a specific instance, the query procedure can be used with /opt/bacula/bin/openstack-vm-query -l
.
The ID can be found under the ID column.
In case the virtual machine was deleted beforehand Cinder backups created by the plugin will have the original virtual machine ID as a name.
To access the list of backup the query procedure can be used with /opt/bacula/bin/openstack-vm-query -b
.
Restore using the instance ID. Get the instance_ID using the /opt/bacula/bin/openstack-vm-query -l
command:
root@stackdev:/opt/bacula# /opt/bacula/bin/openstack-vm-query -l -c /opt/bacula/etc/demo-openrc.sh
+--------------------------------------+---------------+--------+-----------------------+--------------------------+---------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------------+--------+-----------------------+--------------------------+---------+
| e20b1863-6a3f-4b09-90b6-66f77441f3ef | demoInstance1 | ACTIVE | shared=192.168.233.32 | N/A (booted from volume) | m1.tiny |
+--------------------------------------+---------------+--------+-----------------------+--------------------------+---------+
Or list the backups available, and get the instance ID (e20b1863-6a3f-4b09-90b6-66f77441f3ef):
root@stackdev:/opt/bacula# /opt/bacula/bin/openstack-vm-query -b -c /opt/bacula/etc/demo-openrc.sh
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
| ID | Name | Description | Status | Size | Incremental |
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
| 4cbd73d0-8c0e-4808-9900-240c280f1f12 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise | available | 1 | False |
| | | INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM | | | |
| | | UTC 2024 | | | |
| a8967472-ed67-4cb5-8e45-c8781dffe970 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise | available | 2 | False |
| | | INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM | | | |
| | | UTC 2024 | | | |
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
Then issue the restore command using the instance_ID value:
root@stackdev:~# /opt/bacula/bin/openstack-vm-execute-restore -v e20b1863-6a3f-4b09-90b6-66f77441f3ef
Restore of INSTANCE_ID=e20b1863-6a3f-4b09-90b6-66f77441f3ef SCRIPT_PATH=/opt/bacula/bin/ ADMIN_OPENRC=/opt/bacula/etc/admin-openrc.sh
I: 1 backup to restore
I: Restoring 4cbd73d0-8c0e-4808-9900-240c280f1f12
I: Volume restoration in progress=restoring-backup
I: Restored volume found with ID=<restored_volume_ID>
I: Volume restoration in progress=restoring-backup
...
I: Volume restoration in progress=restoring-backup
I: Volume restoration in progress=available
I: Done moving on to next
I: No more backup to restore END
Once this procedure is done, the volumes will be in an available status, and you will need to either create a new instance and attach the restored volumes, or to attach the restored volumes to an existent instance using the openstack CLI or with the GUI from the dashboard.
It is also possible to restore a single volume from a backup id by using the -b
option.
Get the backup_ID for the specific volume using the /opt/bacula/bin/openstack-vm-query -b
command:
root@stackdev:/opt/bacula# /opt/bacula/bin/openstack-vm-query -b -c /opt/bacula/etc/demo-openrc.sh
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
| ID | Name | Description | Status | Size | Incremental |
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
| 4cbd73d0-8c0e-4808-9900-240c280f1f12 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise | available | 1 | False |
| | | INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM | | | |
| | | UTC 2024 | | | |
| a8967472-ed67-4cb5-8e45-c8781dffe970 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise | available | 2 | False |
| | | INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM | | | |
| | | UTC 2024 | | | |
+--------------------------------------+-------------------------------------------------+-----------------------------------------------------+-----------+------+-------------+
Then issue the restore command using the backup ID value, for example:
root@stackdev:~# /opt/bacula/bin/openstack-vm-execute-restore -b 4cbd73d0-8c0e-4808-9900-240c280f1f12
Restore of RESTORE_ID=4cbd73d0-8c0e-4808-9900-240c280f1f12 SCRIPT_PATH=/opt/bacula/bin/ ADMIN_OPENRC=/opt/bacula/etc/demo-openrc.sh
I: 1 backup to restore
I: Restoring backup with ID=4cbd73d0-8c0e-4808-9900-240c280f1f12
I: Found restoration volume in progress ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=restoring-backup
I: Volume restoration in progress with ID=efc209d6-11c4-4bf4-8917-c4e6f07d50b1 STATUS=available
I: Done moving on to next
I: No more backup to restore FINISHED
Create instance from GUI with restored disk
Under the Instances overview select the
Launch Instance
menu.In the source menu select
Volume
fromSelect Boot Source
If the disk containing the operating system has to be restored. Under the
Available
section select the newly restored disk by hitting the up arrow sign on the right
Setup all other parameters, preferably with the same flavor as the backup instance.
Launch instance
Manually attach restored data disks to newly created instance via
Volumes
menuOn the restored disk the
Edit volume
menu contains aManage Volume Attachments
sectionIn the
Attach to instance
sub-menu select the relevant instance to attach the disk to
Use an Admin job to be triggered using bconsole or BWeb
The Admin job configuration to be defined in the Director:
# cat Job/cinder-01-restore-control-job.cfg
Job {
Name = "cinder-01-restore-control-job"
Type = "Admin"
Client = "cinder-01-fd"
Fileset = "Fake-fileset"
Messages = "Default"
Pool = "DiskBackup365d"
Priority = 10
Runscript {
Command = "ssh root@am-u22-openstack-bck \"/opt/bacula/scripts/restore_instance.sh -n e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 -t demo -c -f 1\""
RunsOnClient = no
RunsWhen = Before
}
Schedule = "Manual"
Storage = "DiskAutochanger"
WriteBootstrap = "/opt/bacula/bsr/%c_%n.bsr"
}
The restore_instance.sh
parameters values:
-t demo
is the name of the Tenant.
-f 1
is the flavor of the new instance that will be created. These values you can get from:
# openstack flavor list
+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | 1 | True |
| 2 | m1.small | 2048 | 20 | 0 | 1 | True |
| 3 | m1.medium | 4096 | 40 | 0 | 2 | True |
| 4 | m1.large | 8192 | 80 | 0 | 4 | True |
| 42 | m1.nano | 192 | 1 | 0 | 1 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | 8 | True |
| 84 | m1.micro | 256 | 1 | 0 | 1 | True |
| c1 | cirros256 | 256 | 1 | 0 | 1 | True |
| d1 | ds512M | 512 | 5 | 0 | 1 | True |
| d2 | ds1G | 1024 | 10 | 0 | 1 | True |
| d3 | ds2G | 2048 | 10 | 0 | 2 | True |
| d4 | ds4G | 4096 | 20 | 0 | 4 | True |
+----+-----------+-------+------+-----------+-------+-----------+
-n e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751
is the backup name for the instance demoInstance1 with instance ID e20b1863-6a3f-4b09-90b6-66f77441f3ef
.
This value can be collected by using the following cinder-01-list-backups-job admin job, or command line in the cinder node:
# cat conf.d/Director/am-u24-openstack-dir-tst-dir/Job/cinder-01-list-backups-job.cfg
Job {
Name = "cinder-01-list-backups-job"
Type = "Admin"
Client = "cinder-01-fd"
Fileset = "Fake-fileset"
Messages = "Default"
Pool = "DiskBackup365d"
Priority = 10
Runscript {
Command = "ssh root@am-u22-openstack-bck \"/opt/bacula/scripts/list_backups.sh demo demoInstance1\""
RunsOnClient = no
RunsWhen = Before
}
Schedule = "Manual"
Storage = "DiskAutochanger"
WriteBootstrap = "/opt/bacula/bsr/%c_%n.bsr"
}
The cinder-01-list-backups-job
job log to list all the backups for the demoInstance1
instance:
2024-10-14 11:50:21 am-u24-openstack-dir-tst-dir JobId 451: shell command: run BeforeJob "ssh root@am-u22-openstack-bck "/opt/bacula/scripts/list_backups.sh demo demoInstance1""
2024-10-14 11:50:22 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: Listing backups for Instance demoInstance1...
2024-10-14 11:50:22 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: Use the backup `Name` to restore all the instance volumes, or use the backup `ID` to restore a single instance volume.
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: +--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: | ID | Name | Description | Status | Size | Incremental |
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: +--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: | 4cbd73d0-8c0e-4808-9900-240c280f1f12 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM UTC 2024 | available | 1 | False |
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: | a8967472-ed67-4cb5-8e45-c8781dffe970 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM UTC 2024 | available | 2 | False |
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: BeforeJob: +--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: Start Admin JobId 451, Job=cinder-01-list-backups-job.2024-10-14_11.50.18_29
2024-10-14 11:50:25 am-u24-openstack-dir-tst-dir JobId 451: Bacula 18.0.4 (06Sep24): 14-Oct-2024 11:50:25
JobId: 451
Job: cinder-01-list-backups-job.2024-10-14_11.50.18_29
Scheduled time: 14-Oct-2024 11:50:18
Start time: 14-Oct-2024 11:50:25
End time: 14-Oct-2024 11:50:25
Termination: Admin OK
And using the openstack-vm-query
procedure in the Cinder node:
# /opt/bacula/bin/openstack-vm-query -c /opt/bacula/etc/demo-openrc.sh -b | grep "^+\|^| ID\|demoInstance1"
+--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
| ID | Name | Description | Status | Size | Incremental |
+--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
| 4cbd73d0-8c0e-4808-9900-240c280f1f12 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM UTC 2024 | available | 1 | False |
| a8967472-ed67-4cb5-8e45-c8781dffe970 | e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 | Backup done by Bacula Enterprise INSTANCE=demoInstance1 DATE=Fri Oct 11 08:02:31 AM UTC 2024 | available | 2 | False |
+--------------------------------------+-------------------------------------------------+----------------------------------------------------------------------------------------------+-----------+------+-------------+
The cinder-01-restore-control-job
job log will report the new instance created:
2024-10-11 13:44:46 openstack-dir- JobId 285: shell command: run BeforeJob "ssh root@am-u22-openstack-bck "/opt/bacula/scripts/restore_instance.sh -v demoInstance1 -n e20b1863-6a3f-4b09-90b6-66f77441f3ef_1728633751 -t demo -c -f c1""
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob:
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | Field | Value |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-DCF:diskConfig | MANUAL |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-AZ:availability_zone | nova |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:host | am-u22-openstack-bck |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:hostname | demoinstance1-restored |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:hypervisor_hostname | am-u22-openstack-bck |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:instance_name | instance-00000014 |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:kernel_id | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:launch_index | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:ramdisk_id | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:reservation_id | r-5drlfobi |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-SRV-ATTR:user_data | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-STS:power_state | Running |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-STS:task_state | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-EXT-STS:vm_state | active |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-SRV-USG:launched_at | 2024-10-11T13:47:56.000000 |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | OS-SRV-USG:terminated_at | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | accessIPv4 | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | accessIPv6 | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | addresses | N/A |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | adminPass | JiVRLeB59PCG |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | config_drive | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | created | 2024-10-11T13:47:23Z |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | description | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | flavor | description=, disk='1', ephemeral='0', extra_specs.hw_rng:allowed='True', id='cirros256', is_disabled=, is_public='True', location=, name='cirros256', original_name='cirros256', ram='256', rxtx_factor=, swap='0', vcpus='1' |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | hostId | 321b77de1457d2ad95d696392b037a456230edc2009395d7dd924b6c |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | host_status | UP |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | id | 5854acee-28d4-4029-944a-ccef9fc88b5d |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | image | N/A (booted from volume) |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | key_name | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | locked | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | locked_reason | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | name | demoInstance1_restored |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | pinned_availability_zone | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | progress | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | project_id | 9c8aa25a903346e6af3877a6b4612a46 |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | properties | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | security_groups | name='default' |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | server_groups | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | status | ACTIVE |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | tags | |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | trusted_image_certificates | None |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | updated | 2024-10-11T13:47:56Z |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | user_id | 362d7bb6fcc64be3bcdc1c6fc99229d0 |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: | volumes_attached | delete_on_termination='False', id='efc209d6-11c4-4bf4-8917-c4e6f07d50b1' |
2024-10-11 13:48:00 openstack-dir JobId 285: BeforeJob: +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: +-----------------------+--------------------------------------+
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Field | Value |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: +-----------------------+--------------------------------------+
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | ID | 83989c2c-7bb0-4c8e-91c7-511a6e7836fb |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Server ID | 5854acee-28d4-4029-944a-ccef9fc88b5d |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Volume ID | 83989c2c-7bb0-4c8e-91c7-511a6e7836fb |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Device | /dev/vdb |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Tag | None |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: | Delete On Termination | False |
2024-10-11 13:48:08 openstack-dir JobId 285: BeforeJob: +-----------------------+--------------------------------------+
2024-10-11 13:48:08 openstack-dir JobId 285: Start Admin JobId 285, Job=cinder-01-restore-control-job.2024-10-11_13.44.44_09
2024-10-11 13:48:08 openstack-dir JobId 285: Bacula 18.0.4 (06Sep24): 11-Oct-2024 13:48:08
JobId: 285
Job: cinder-01-restore-control-job.2024-10-11_13.44.44_09
Scheduled time: 11-Oct-2024 13:44:44
Start time: 11-Oct-2024 13:48:08
End time: 11-Oct-2024 13:48:08
Termination: Admin OK
Note
The scripts trigger-cinder-backup.sh
, list_backups
, and restore_instances.sh
mentioned may not be readily available in the
OpenStack VM Plugin. However, users have the flexibility to create and customize these scripts according to their specific needs and
preferences.
Go back to the main Openstack VM page.