diff options
| author | Lingxian Kong <anlin.kong@gmail.com> | 2021-02-20 09:51:57 +1300 |
|---|---|---|
| committer | Lingxian Kong <anlin.kong@gmail.com> | 2021-02-21 00:37:08 +1300 |
| commit | c7319d8fe8cb6cfd5c423472283aadffb12ed52c (patch) | |
| tree | 77e269a79927c26cd084f6cdf7e13296d620f0a8 /troveclient/v1/backups.py | |
| parent | 4c71809fadc070aa0f1ec3b4082546d4d2cf0d51 (diff) | |
| download | python-troveclient-wallaby-em.tar.gz | |
Support to restore backup from data locationwallaby-em7.0.0
This feature needs to bump python-troveclient major version as it
introduced an incompatible change for backup creation CLI.
Change-Id: I6fe94ccb552e2c0020150494ccc2ba6361184229
Diffstat (limited to 'troveclient/v1/backups.py')
| -rw-r--r-- | troveclient/v1/backups.py | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/troveclient/v1/backups.py b/troveclient/v1/backups.py index 4c5498e..4e309dd 100644 --- a/troveclient/v1/backups.py +++ b/troveclient/v1/backups.py @@ -75,8 +75,9 @@ class Backups(base.ManagerWithFind): query_strings) def create(self, name, instance, description=None, - parent_id=None, incremental=False, swift_container=None): - """Create a new backup from the given instance. + parent_id=None, incremental=False, swift_container=None, + restore_from=None, restore_ds_version=None, restore_size=None): + """Create or restore a new backup. :param name: name for backup. :param instance: instance to backup. @@ -85,23 +86,38 @@ class Backups(base.ManagerWithFind): :param incremental: flag to indicate incremental backup based on last backup :param swift_container: Swift container name. + :param restore_from: The original backup data location, typically this + is a Swift object URL. + :param restore_ds_version: ID of the local datastore version + corresponding to the original backup. + :param restore_size: The original backup size. :returns: :class:`Backups` """ body = { "backup": { "name": name, - "incremental": int(incremental) } } - if instance: - body['backup']['instance'] = base.getid(instance) - if description: - body['backup']['description'] = description - if parent_id: - body['backup']['parent_id'] = parent_id - if swift_container: - body['backup']['swift_container'] = swift_container + if restore_from: + body['backup'].update({ + 'restore_from': { + 'remote_location': restore_from, + 'local_datastore_version_id': restore_ds_version, + 'size': restore_size + } + }) + else: + body['backup']['incremental'] = int(incremental) + if instance: + body['backup']['instance'] = base.getid(instance) + if description: + body['backup']['description'] = description + if parent_id: + body['backup']['parent_id'] = parent_id + if swift_container: + body['backup']['swift_container'] = swift_container + return self._create("/backups", body, "backup") def delete(self, backup): |
