ioctx.close()
client.shutdown()
- def _get_backup_rbd_name(self, vol_name, backup_id):
- """Make sure we use a consistent format for backup names"""
- # ensure no unicode
- return str("%s.backup.%s" % (vol_name, backup_id))
+ def _get_backup_base_name(self, volume_id, backup_id):
+ """Return name of base image used for backup."""
+ # Ensure no unicode
+ return str("volume-%s.backup.%s" % (volume_id, backup_id))
def _transfer_data(self, src, dest, dest_name, length, dest_is_rbd=False):
"""
"""Backup the given volume to Ceph object store"""
backup_id = backup['id']
volume = self.db.volume_get(self.context, backup['volume_id'])
- backup_name = self._get_backup_rbd_name(volume['name'], backup_id)
+ backup_name = self._get_backup_base_name(volume['id'], backup_id)
LOG.debug("Starting backup of volume='%s' to rbd='%s'" %
(volume['name'], backup_name))
def restore(self, backup, volume_id, volume_file):
"""Restore the given volume backup from Ceph object store"""
- volume_id = backup['volume_id']
volume = self.db.volume_get(self.context, volume_id)
- backup_name = self._get_backup_rbd_name(volume['name'], backup['id'])
+ backup_name = self._get_backup_base_name(backup['volume_id'],
+ backup['id'])
LOG.debug('starting backup restore from Ceph backup=%s '
'to volume=%s' % (backup['id'], volume['name']))
def delete(self, backup):
"""Delete the given backup from Ceph object store"""
backup_id = backup['id']
- volume_id = backup['volume_id']
- volume = self.db.volume_get(self.context, volume_id)
- backup_name = self._get_backup_rbd_name(volume['name'], backup_id)
+ backup_name = self._get_backup_base_name(backup['volume_id'],
+ backup_id)
LOG.debug('delete started for backup=%s', backup['id'])
def restore_backup(self, context, backup, volume, backup_service):
"""Restore an existing backup to a new or existing volume."""
- volume = self.db.volume_get(context, backup['volume_id'])
pool = self.configuration.rbd_pool
with RBDVolumeProxy(self, volume['name'], pool) as rbd_image: