0
# Azure Recovery Services Backup
1
2
The Azure Recovery Services Backup Management Client Library provides comprehensive Python interfaces for managing Azure Backup services through the Azure Resource Manager API. It enables programmatic interaction with Azure Backup operations including vault management, backup policy configuration, backup item management, restore operations, and job monitoring.
3
4
## Package Information
5
6
- **Package Name**: azure-mgmt-recoveryservicesbackup
7
- **Language**: Python
8
- **Installation**: `pip install azure-mgmt-recoveryservicesbackup azure-identity`
9
- **Python Support**: 3.8+
10
11
## Core Imports
12
13
```python
14
from azure.identity import DefaultAzureCredential
15
from azure.mgmt.recoveryservicesbackup.activestamp import RecoveryServicesBackupClient
16
from azure.mgmt.recoveryservicesbackup.passivestamp import RecoveryServicesBackupPassiveClient
17
```
18
19
For asynchronous operations:
20
21
```python
22
from azure.mgmt.recoveryservicesbackup.activestamp.aio import RecoveryServicesBackupClient as AsyncRecoveryServicesBackupClient
23
from azure.mgmt.recoveryservicesbackup.passivestamp.aio import RecoveryServicesBackupPassiveClient as AsyncRecoveryServicesBackupPassiveClient
24
```
25
26
## Basic Usage
27
28
```python
29
import os
30
from azure.identity import DefaultAzureCredential
31
from azure.mgmt.recoveryservicesbackup.activestamp import RecoveryServicesBackupClient
32
33
# Authentication using environment variables:
34
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID
35
credential = DefaultAzureCredential()
36
subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")
37
38
# Create the main backup client
39
client = RecoveryServicesBackupClient(
40
credential=credential,
41
subscription_id=subscription_id
42
)
43
44
# List backup policies in a resource group
45
resource_group_name = "my-resource-group"
46
vault_name = "my-backup-vault"
47
48
policies = client.backup_policies.list(
49
resource_group_name=resource_group_name,
50
vault_name=vault_name
51
)
52
53
for policy in policies:
54
print(f"Policy: {policy.name}, Type: {policy.properties.backup_management_type}")
55
56
# Get backup status for a virtual machine
57
vm_resource_group = "vm-resource-group"
58
vm_name = "my-vm"
59
60
backup_status = client.backup_status.get(
61
azure_region="eastus",
62
parameters={
63
"resource_type": "VM",
64
"resource_id": f"/subscriptions/{subscription_id}/resourceGroups/{vm_resource_group}/providers/Microsoft.Compute/virtualMachines/{vm_name}",
65
"poQuery_type": "BackupStatus"
66
}
67
)
68
69
print(f"Protection status: {backup_status.protection_info.protection_status}")
70
```
71
72
## Architecture
73
74
The library provides two main API variants designed for different backup scenarios:
75
76
- **ActiveStamp API**: Comprehensive backup operations for primary backup management (API version 2025-02-01)
77
- **PassiveStamp API**: Specialized for Cross-Region Restore (CRR) scenarios (API version 2021-11-15)
78
79
Both variants offer:
80
- **Synchronous clients** for traditional blocking operations
81
- **Asynchronous clients** for high-performance async/await operations
82
- **Comprehensive operation coverage** with 108+ operation classes
83
- **Rich data models** with 400+ model classes and 100+ enums
84
85
## Capabilities
86
87
### Client Management
88
89
Core client initialization and configuration for both ActiveStamp and PassiveStamp APIs, including authentication, subscription management, and client lifecycle operations.
90
91
```python { .api }
92
class RecoveryServicesBackupClient:
93
def __init__(
94
self,
95
credential: TokenCredential,
96
subscription_id: str,
97
base_url: str = "https://management.azure.com",
98
**kwargs
99
): ...
100
101
class RecoveryServicesBackupPassiveClient:
102
def __init__(
103
self,
104
credential: TokenCredential,
105
subscription_id: str,
106
base_url: str = "https://management.azure.com",
107
**kwargs
108
): ...
109
```
110
111
[Client Management](./client-management.md)
112
113
### Backup Policies
114
115
Comprehensive backup policy management including creation, modification, deletion, and assignment of backup policies. Supports various workload types including Azure VMs, SQL databases, file shares, and on-premises workloads.
116
117
```python { .api }
118
class BackupPoliciesOperations:
119
def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[ProtectionPolicyResource]: ...
120
121
class ProtectionPoliciesOperations:
122
def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> ProtectionPolicyResource: ...
123
def create_or_update(self, resource_group_name: str, vault_name: str, policy_name: str, parameters: ProtectionPolicyResource, **kwargs) -> ProtectionPolicyResource: ...
124
def delete(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> None: ...
125
```
126
127
[Backup Policies](./backup-policies.md)
128
129
### Protected Items
130
131
Management of items under backup protection including virtual machines, databases, file shares, and workloads. Provides operations for enabling protection, modifying protection settings, and removing protection.
132
133
```python { .api }
134
class BackupProtectedItemsOperations:
135
def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[BackupProtectedItemResource]: ...
136
137
class ProtectedItemsOperations:
138
def get(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, **kwargs) -> BackupProtectedItemResource: ...
139
def create_or_update(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, parameters: BackupProtectedItemResource, **kwargs) -> BackupProtectedItemResource: ...
140
def delete(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, **kwargs) -> None: ...
141
```
142
143
[Protected Items](./protected-items.md)
144
145
### Backup Operations
146
147
Execution and management of backup operations including on-demand backups, backup scheduling, and backup job monitoring. Supports all Azure Backup workload types with comprehensive status tracking.
148
149
```python { .api }
150
class BackupsOperations:
151
def trigger(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, parameters: BackupRequestResource, **kwargs) -> None: ...
152
153
class BackupJobsOperations:
154
def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[JobResource]: ...
155
156
class JobDetailsOperations:
157
def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> JobResource: ...
158
159
class JobCancellationsOperations:
160
def trigger(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> None: ...
161
```
162
163
[Backup Operations](./backup-operations.md)
164
165
### Restore Operations
166
167
Comprehensive restore capabilities including full restore, file-level restore, and cross-region restore. Supports various restore targets and scenarios with detailed restore job tracking and management.
168
169
```python { .api }
170
class RestoresOperations:
171
def trigger(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, recovery_point_id: str, parameters: RestoreRequestResource, **kwargs) -> None: ...
172
173
class RecoveryPointsOperations:
174
def list(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, **kwargs) -> Iterable[RecoveryPointResource]: ...
175
def get(self, resource_group_name: str, vault_name: str, fabric_name: str, container_name: str, protected_item_name: str, recovery_point_id: str, **kwargs) -> RecoveryPointResource: ...
176
```
177
178
[Restore Operations](./restore-operations.md)
179
180
### Cross-Region Restore
181
182
Specialized operations for Cross-Region Restore (CRR) scenarios using the PassiveStamp API. Enables backup and restore operations across Azure regions for disaster recovery and compliance requirements.
183
184
```python { .api }
185
class CrossRegionRestoreOperations:
186
def trigger(self, azure_region: str, parameters: CrossRegionRestoreRequestResource, **kwargs) -> None: ...
187
def get_operation_status(self, azure_region: str, operation_id: str, **kwargs) -> OperationStatus: ...
188
```
189
190
[Cross-Region Restore](./cross-region-restore.md)
191
192
### Vault Configuration
193
194
Management of Recovery Services vault settings including storage configuration, encryption settings, and vault-level policies. Provides comprehensive vault administration capabilities.
195
196
```python { .api }
197
class BackupResourceVaultConfigsOperations:
198
def get(self, resource_group_name: str, vault_name: str, **kwargs) -> BackupResourceVaultConfigResource: ...
199
def update(self, resource_group_name: str, vault_name: str, parameters: BackupResourceVaultConfigResource, **kwargs) -> BackupResourceVaultConfigResource: ...
200
201
class BackupResourceStorageConfigsOperations:
202
def get(self, resource_group_name: str, vault_name: str, **kwargs) -> BackupResourceStorageConfigResource: ...
203
def update(self, resource_group_name: str, vault_name: str, parameters: BackupResourceStorageConfigResource, **kwargs) -> None: ...
204
```
205
206
[Vault Configuration](./vault-configuration.md)
207
208
### Job Management
209
210
Comprehensive backup and restore job lifecycle management including job monitoring, cancellation, result retrieval, and detailed status tracking across all supported workload types.
211
212
```python { .api }
213
class BackupJobsOperations:
214
def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[JobResource]: ...
215
216
class JobDetailsOperations:
217
def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> JobResource: ...
218
219
class JobCancellationsOperations:
220
def trigger(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> None: ...
221
222
class JobsOperations:
223
def export(self, resource_group_name: str, vault_name: str, **kwargs) -> None: ...
224
```
225
226
[Job Management](./job-management.md)
227
228
## Common Types
229
230
```python { .api }
231
# Base resource types
232
class Resource:
233
id: Optional[str]
234
name: Optional[str]
235
type: Optional[str]
236
location: Optional[str]
237
tags: Optional[Dict[str, str]]
238
239
class ProxyResource(Resource):
240
pass
241
242
# Backup management types
243
class BackupManagementType(str, Enum):
244
AZURE_IAAS_VM = "AzureIaasVM"
245
AZURE_STORAGE = "AzureStorage"
246
AZURE_WORKLOAD = "AzureWorkload"
247
DPM = "DPM"
248
MABS = "MABS"
249
INVALID = "Invalid"
250
251
# Workload types
252
class WorkloadType(str, Enum):
253
VM = "VM"
254
FILE_SHARE = "FileShare"
255
SQL_DB = "SQLDB"
256
SAP_HANA_DATABASE = "SAPHanaDatabase"
257
EXCHANGE = "Exchange"
258
SHAREPOINT = "Sharepoint"
259
INVALID = "Invalid"
260
261
# Job status enumeration
262
class JobStatus(str, Enum):
263
INVALID = "Invalid"
264
IN_PROGRESS = "InProgress"
265
COMPLETED = "Completed"
266
FAILED = "Failed"
267
COMPLETED_WITH_WARNINGS = "CompletedWithWarnings"
268
CANCELLED = "Cancelled"
269
CANCELLING = "Cancelling"
270
```