Cloud Backup and Recovery (CBR)¶
Cloud Backup and Recovery (CBR) enables you to back up Elastic Cloud Servers (ECSs) and Elastic Volume Service (EVS) disks with ease. If there is a virus intrusion, accidental deletion, or software or hardware fault, you can restore data to any point in the past when the data was backed up. CBR protects your services by ensuring the security and consistency of your data.
Backup¶
A backup is a copy of the original data that is backed up. A backup is used to restore the original data.
List CBR Backups¶
This interface is used to query CBR backups and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for backup in conn.cbr.backups():
print(backup)
Get CBR Backup¶
This interface is used to get a CBR backup by ID or an instance of
class Backup
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
backup = 'backup_id'
backup = conn.cbr.get_backup(backup=backup)
print(backup)
Find CBR Backup¶
This interface is used to find a CBR backup by name or ID. The return value
is a instance of class
Backup
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
name_or_id = 'name_or_id'
backup = conn.cbr.find_backup(name_or_id)
print(backup)
Delete CBR Backup¶
This interface is used to delete a CBR backup instance by id
or an instance of class
Backup
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
name_or_id = 'name_or_id'
backup = conn.cbr.find_backup(name_or_id)
conn.cbr.delete_backup(backup=backup)
Policy¶
List CBR Policies¶
This interface is used to query CBR policies and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for policies in conn.cbr.policies():
print(policies)
Get CBR Policy¶
This interface is used to get a CBR policy by ID or an instance of
class Policy
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
policy = 'policy_id'
policy = conn.cbr.get_policy(policy)
print(policy)
Create CBR Policy¶
This interface is used to create a CBR policy instance with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'enabled': True,
'name': 'my_policy',
'operation_definition': {
'day_backups': 0,
'month_backups': 0,
'max_backups': 1,
'timezone': 'UTC+08:00',
'week_backups': 0,
'year_backups': 0
},
'operation_type': 'backup',
'trigger': {
'properties': {
'pattern': [
'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00'
]
}
}
}
policy = conn.cbr.create_policy(**attrs)
print(policy)
Update CBR Policy¶
This interface is used to update a CBR policy instance with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'enabled': True,
'name': 'policy001',
'operation_definition': {
'day_backups': 0,
'month_backups': 0,
'max_backups': 1,
'timezone': 'UTC+08:00',
'week_backups': 0,
'year_backups': 0
},
'trigger': {
'properties': {
'pattern': [
'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00'
]
}
}
}
policy = 'name_or_id'
policy = conn.cbr.find_policy(name_or_id=policy)
policy = conn.cbr.update_policy(policy=policy, **attrs)
print(policy)
Delete CBR Policy¶
This interface is used to delete a CBR policy instance by id
or an instance of class
Policy
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
policy = '52606d56-d129-44d1-85da-1cc7b837942e'
policy = conn.cbr.find_policy(name_or_id=policy)
conn.cbr.delete_policy(policy=policy)
Restore Point (Checkpoint)¶
Restore points are used to create backups of resources attached to a vault.
Get CBR Restore Point (Checkpoint)¶
This interface is used to get a CBR restore point by ID or an instance of
class Checkpoint
.
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
checkpoint = 'checkpoint_id'
checkpoint = conn.cbr.get_checkpoint(checkpoint=checkpoint)
print(checkpoint)
Create CBR Restore Point (Checkpoint)¶
This interface is used to create a CBR Restore point instance with parameters.
from otcextensions import sdk
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
sdk.register_otc_extensions(conn)
attrs = {
'parameters': {
'auto_trigger': False,
'description': 'backup_description',
'incremental': False,
'name': 'manual_backup',
'resources': [
'ecs_id'
]
},
'vault_id': 'vault_id'
Restore¶
Restore Data¶
This interface is used to restore data from a backup to server instances or volumes.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
backup = 'name_or_id_backup'
disk_backup = 'name_or_id_disk_backup'
ecs = 'server_name_or_id'
volume = 'volume_id'
attrs = {
'mappings': [{
'backup_id': disk_backup,
'volume_id': volume
}],
'power_on': True,
'server_id': ecs
}
result = conn.cbr.restore_data(backup=backup, **attrs)
print(result)
Vault¶
List CBR Vaults¶
This interface is used to query CBR vaults and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for vault in conn.cbr.vaults():
print(vault)
Get CBR Vault¶
This interface is used to get a CBR vault by ID or an instance of
class Vault
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
vault = 'vault_id'
vault = conn.cbr.get_vault(vault=vault)
print(vault)
Create CBR Vault¶
This interface is used to create a CBR vault instance with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'description': 'my vault',
'auto_bind': False,
'bind_rules': {},
'name': 'vault-name',
'billing': {
'protect_type': 'backup',
'object_type': 'server',
'size': 40,
'cloud_type': 'public',
'consistent_level': 'crash_consistent',
'charging_mode': 'post_paid'
},
'auto_expand': False,
'resources': [
{
'name': 'server-name',
'type': 'OS::Nova::Server',
'id': 'server-id',
}
]
}
vault = conn.cbr.create_vault(**attrs)
print(vault)
Update CBR Vault¶
This interface is used to update a CBR vault instance with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'name': 'vault2'
}
vault = 'vault1'
vault = conn.cbr.find_find(name_or_id=vault)
vault = conn.cbr.update_vault(vault=vault, **attrs)
print(vault)
Delete CBR Vault¶
This interface is used to delete a CBR vault instance by id
or an instance of class
Vault
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
name_or_id = 'name_or_id'
vault = conn.cbr.find_vault(name_or_id)
conn.cbr.delete_vault(vault=vault)
Bind Policy to CBR Vault¶
This interface is used to bind a CBR policy to a CBR vault.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
policy = 'name_or_id'
vault = 'name_or_id'
policy = conn.cbr.find_policy(policy)
vault = conn.cbr.find_vault(vault)
conn.cbr.bind_policy(vault=vault.id, policy=policy.id)
Unbind Policy to CBR Vault¶
This interface is used to release a CBR policy from a CBR vault.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
policy = 'name_or_id'
vault = 'name_or_id'
policy = conn.cbr.find_policy(policy)
vault = conn.cbr.find_vault(vault)
conn.cbr.unbind_policy(vault=vault.id, policy=policy.id)
Associate resources to CBR Vault¶
This interface is used to add resources to a CBR vault.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
vault = 'vault_name_or_id'
resources = [{
'id': 'server_id',
'type': 'OS::Nova::Server'}]
vault = conn.cbr.find_vault(vault)
conn.cbr.associate_resources(vault=vault.id, resources=resources)
Dissociate resources from CBR Vault¶
This interface is used to remove resources from CBR vault.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
vault = 'vault_name_or_id'
resources = [
'list_of_resource_ids',
]
vault = conn.cbr.find_vault(vault)
conn.cbr.dissociate_resources(vault=vault.id, resources=resources)
Member¶
This API is used to add a member with whom the backup can be shared. Only cloud server backups can be shared among tenants in the same region.
Task¶
List CBR Tasks¶
This interface is used to query CBR tasks and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for task in conn.cbr.tasks():
print(task)
Get CBR Task¶
This interface is used to get a CBR task by ID or an instance of
class Task
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
task = 'task_id'
task = conn.cbr.get_task(task)
print(task)