Back up and restore Glance images

Back up and restore Glance imagesΒΆ

This section instructs you on how to back up and restore Glance images and covers both the local storage and the Ceph back end for Glance configurations. Both procedures presuppose that the Glance API is in the working state.

To back up Glance images:

  1. Log in to the Salt Master node.

  2. Verify that there is enough space on the OpenStack controller node to which you will copy the Glance images.

  3. Copy the images to the backup destination preserving the context. For example, to copy the images to the ctl01 node:

    salt -C 'I@glance:server and *01*' cmd.run '. /root/keystonercv3; cd <PATH_TO_BACKUP>; for i in `openstack image list -c ID -f value`; \
    do openstack image save --file $i $i; done'
    
  4. If needed, move the backed up images to the external backup location.

To restore Glance images:

  1. Log in to the Salt Master node.

  2. If needed, copy the images from the external backup location to an OpenStack controller node.

  3. Copy the images from the OpenStack controller node to the Glance folder with the images. In the example commands below, the ctl01 node is used as the OpenStack controller node containing the backed up Glance images:

    Note

    GlusterFS will automatically replicate the restored images to all other OpenStack controller nodes.

    • If the local storage is used, run:

      salt -C 'I@glance:server and *01*' cmd.run "cp -a <PATH_TO_BACKUP>/. /var/lib/glance/images/"
      
    • If the Ceph back end is used, run:

      salt -C 'I@glance:server and *01*' cmd.run ". /root/keystonercv3; cd <PATH_TO_BACKUP>; for i in `openstack image list -c ID -f value`; \
      do rbd import -p images $i; rbd snap create -p images $i@snap; done"
      
  4. Verify that the restored Glance images are available:

    salt -C 'I@keystone:client' cmd.run ". /root/keystonercv3; openstack image list"
    

    Note

    If the context of the Glance images files is lost, run:

    salt -C 'I@glance:server' cmd.run "chown glance:glance <IMAGE_FILE_NAME>"
    salt -C 'I@glance:server' cmd.run "chmod 640 <IMAGE_FILE_NAME>"