Skip to content

Commit e630ebc

Browse files
author
cmart
committed
Always use direct backup, passing force flag to back up in-use volumes
1 parent 11c7de8 commit e630ebc

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

cinderback.py

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -578,51 +578,18 @@ def backup_volume(self, volume, name=None, client=None):
578578
# Use encoded original volume info as description
579579
description = BackupInfo(volume)
580580

581-
if volume.status == 'in-use':
582-
_LI('Volume online so this is a multi-step process')
583-
584-
# Force snapshot since volume it's in-use
585-
snapshot = self._create_and_wait(
586-
'Creating snapshot', client.volume_snapshots,
587-
arguments=dict(
588-
volume_id=volume.id, force=True, name='tmp ' + name,
589-
description='Temporary snapshot for backup',
590-
metadata=volume.metadata))
591-
592-
# Create temporary volume from snapshot
593-
tmp_vol = self._create_and_wait(
594-
'Creating temp volume from snapshot', client.volumes,
595-
arguments=dict(
596-
size=snapshot.size, snapshot_id=snapshot.id,
597-
name='tmp '+name,
598-
description='Temporary volume for backup',
599-
metadata=volume.metadata), resources=(snapshot,))
600-
601-
# Backup temporary volume
602-
backup = self._create_and_wait(
603-
'Doing the actual backup', client.backups,
604-
arguments=dict(
605-
volume_id=tmp_vol.id, name=name, container=None,
606-
description=str(description)),
607-
resources=(snapshot, tmp_vol))
608-
609-
# Cleanup temporary resources
610-
_LI('Deleting temporary volume and snapshot')
611-
tmp_vol.delete()
612-
snapshot.delete()
613-
614-
elif volume.status == 'available':
581+
if volume.status in ['available', 'in-use']:
615582
backup = self._create_and_wait(
616-
'Creating direct backup', client.backups,
583+
'Creating backup', client.backups,
617584
arguments=dict(
618585
volume_id=volume.id, name=name, container=None,
619-
description=str(description)))
586+
description=str(description), force=True))
587+
return backup
620588

621589
else:
622590
_LE("We don't backup volume because status is %s", volume.status)
623591
raise UnexpectedStatus(what=volume)
624592

625-
return backup
626593

627594
def _is_auto_backup(self, backup):
628595
"""Check if a backup was created by us."""

0 commit comments

Comments
 (0)