0
# Point-in-Time Restore Operations
1
2
Comprehensive point-in-time restore capabilities for discovering restorable resources across all APIs and time ranges. These operations enable precise backup and recovery scenarios by providing detailed information about what resources can be restored and from which points in time.
3
4
## Capabilities
5
6
### Restorable Database Account Discovery
7
8
Discover database accounts that can be restored from a specific time range and location.
9
10
```python { .api }
11
def list(self) -> ItemPaged[RestorableDatabaseAccountGetResult]:
12
"""
13
List all restorable database accounts in the subscription.
14
15
Returns:
16
ItemPaged[RestorableDatabaseAccountGetResult]: Paginated list of restorable accounts
17
"""
18
19
def list_by_location(self, location: str) -> ItemPaged[RestorableDatabaseAccountGetResult]:
20
"""
21
List restorable database accounts in a specific location.
22
23
Parameters:
24
- location: Azure region name (e.g., "East US", "West Europe")
25
26
Returns:
27
ItemPaged[RestorableDatabaseAccountGetResult]: Paginated list of restorable accounts in the location
28
"""
29
30
def get_by_location(
31
self,
32
location: str,
33
instance_id: str
34
) -> RestorableDatabaseAccountGetResult:
35
"""
36
Get details of a restorable database account by location and instance ID.
37
38
Parameters:
39
- location: Azure region name
40
- instance_id: Unique identifier of the database account instance
41
42
Returns:
43
RestorableDatabaseAccountGetResult: Restorable account details and timeline
44
"""
45
```
46
47
### SQL API Restore Discovery
48
49
Discover restorable SQL API resources including databases, containers, and related resources.
50
51
```python { .api }
52
def list(
53
self,
54
location: str,
55
instance_id: str,
56
restore_location: Optional[str] = None,
57
restore_timestamp_in_utc: Optional[str] = None
58
) -> ItemPaged[RestorableSqlResourcesGetResult]:
59
"""
60
List all restorable SQL resources for a database account.
61
62
Parameters:
63
- location: Location of the source account
64
- instance_id: Instance ID of the source account
65
- restore_location: Target location for restore (optional)
66
- restore_timestamp_in_utc: Restore point in UTC (optional)
67
68
Returns:
69
ItemPaged[RestorableSqlResourcesGetResult]: Paginated list of restorable SQL resources
70
"""
71
72
def list_sql_databases(
73
self,
74
location: str,
75
instance_id: str,
76
start_time: Optional[str] = None,
77
end_time: Optional[str] = None
78
) -> ItemPaged[RestorableSqlDatabaseGetResult]:
79
"""
80
List restorable SQL databases for a specific account and time range.
81
82
Parameters:
83
- location: Location of the source account
84
- instance_id: Instance ID of the source account
85
- start_time: Start time for the restore range in UTC
86
- end_time: End time for the restore range in UTC
87
88
Returns:
89
ItemPaged[RestorableSqlDatabaseGetResult]: Paginated list of restorable databases
90
"""
91
92
def list_sql_containers(
93
self,
94
location: str,
95
instance_id: str,
96
database_rid: str,
97
start_time: Optional[str] = None,
98
end_time: Optional[str] = None
99
) -> ItemPaged[RestorableSqlContainerGetResult]:
100
"""
101
List restorable SQL containers in a database for a specific time range.
102
103
Parameters:
104
- location: Location of the source account
105
- instance_id: Instance ID of the source account
106
- database_rid: Resource ID of the database
107
- start_time: Start time for the restore range in UTC
108
- end_time: End time for the restore range in UTC
109
110
Returns:
111
ItemPaged[RestorableSqlContainerGetResult]: Paginated list of restorable containers
112
"""
113
```
114
115
### MongoDB API Restore Discovery
116
117
Discover restorable MongoDB API resources including databases, collections, and configurations.
118
119
```python { .api }
120
def list(
121
self,
122
location: str,
123
instance_id: str,
124
restore_location: Optional[str] = None,
125
restore_timestamp_in_utc: Optional[str] = None
126
) -> ItemPaged[RestorableMongodbResourcesGetResult]:
127
"""
128
List all restorable MongoDB resources for a database account.
129
130
Parameters:
131
- location: Location of the source account
132
- instance_id: Instance ID of the source account
133
- restore_location: Target location for restore (optional)
134
- restore_timestamp_in_utc: Restore point in UTC (optional)
135
136
Returns:
137
ItemPaged[RestorableMongodbResourcesGetResult]: Paginated list of restorable MongoDB resources
138
"""
139
140
def list_mongodb_databases(
141
self,
142
location: str,
143
instance_id: str,
144
start_time: Optional[str] = None,
145
end_time: Optional[str] = None
146
) -> ItemPaged[RestorableMongodbDatabaseGetResult]:
147
"""
148
List restorable MongoDB databases for a specific account and time range.
149
150
Parameters:
151
- location: Location of the source account
152
- instance_id: Instance ID of the source account
153
- start_time: Start time for the restore range in UTC
154
- end_time: End time for the restore range in UTC
155
156
Returns:
157
ItemPaged[RestorableMongodbDatabaseGetResult]: Paginated list of restorable databases
158
"""
159
160
def list_mongodb_collections(
161
self,
162
location: str,
163
instance_id: str,
164
database_rid: str,
165
start_time: Optional[str] = None,
166
end_time: Optional[str] = None
167
) -> ItemPaged[RestorableMongodbCollectionGetResult]:
168
"""
169
List restorable MongoDB collections in a database for a specific time range.
170
171
Parameters:
172
- location: Location of the source account
173
- instance_id: Instance ID of the source account
174
- database_rid: Resource ID of the database
175
- start_time: Start time for the restore range in UTC
176
- end_time: End time for the restore range in UTC
177
178
Returns:
179
ItemPaged[RestorableMongodbCollectionGetResult]: Paginated list of restorable collections
180
"""
181
```
182
183
### Gremlin API Restore Discovery
184
185
Discover restorable Gremlin API resources including databases and graphs.
186
187
```python { .api }
188
def list(
189
self,
190
location: str,
191
instance_id: str,
192
restore_location: Optional[str] = None,
193
restore_timestamp_in_utc: Optional[str] = None
194
) -> ItemPaged[RestorableGremlinResourcesGetResult]:
195
"""
196
List all restorable Gremlin resources for a database account.
197
198
Parameters:
199
- location: Location of the source account
200
- instance_id: Instance ID of the source account
201
- restore_location: Target location for restore (optional)
202
- restore_timestamp_in_utc: Restore point in UTC (optional)
203
204
Returns:
205
ItemPaged[RestorableGremlinResourcesGetResult]: Paginated list of restorable Gremlin resources
206
"""
207
208
def list_gremlin_databases(
209
self,
210
location: str,
211
instance_id: str,
212
start_time: Optional[str] = None,
213
end_time: Optional[str] = None
214
) -> ItemPaged[RestorableGremlinDatabaseGetResult]:
215
"""
216
List restorable Gremlin databases for a specific account and time range.
217
218
Parameters:
219
- location: Location of the source account
220
- instance_id: Instance ID of the source account
221
- start_time: Start time for the restore range in UTC
222
- end_time: End time for the restore range in UTC
223
224
Returns:
225
ItemPaged[RestorableGremlinDatabaseGetResult]: Paginated list of restorable databases
226
"""
227
228
def list_gremlin_graphs(
229
self,
230
location: str,
231
instance_id: str,
232
database_rid: str,
233
start_time: Optional[str] = None,
234
end_time: Optional[str] = None
235
) -> ItemPaged[RestorableGremlinGraphGetResult]:
236
"""
237
List restorable Gremlin graphs in a database for a specific time range.
238
239
Parameters:
240
- location: Location of the source account
241
- instance_id: Instance ID of the source account
242
- database_rid: Resource ID of the database
243
- start_time: Start time for the restore range in UTC
244
- end_time: End time for the restore range in UTC
245
246
Returns:
247
ItemPaged[RestorableGremlinGraphGetResult]: Paginated list of restorable graphs
248
"""
249
```
250
251
### Table API Restore Discovery
252
253
Discover restorable Table API resources.
254
255
```python { .api }
256
def list(
257
self,
258
location: str,
259
instance_id: str,
260
restore_location: Optional[str] = None,
261
restore_timestamp_in_utc: Optional[str] = None
262
) -> ItemPaged[RestorableTableResourcesGetResult]:
263
"""
264
List all restorable table resources for a database account.
265
266
Parameters:
267
- location: Location of the source account
268
- instance_id: Instance ID of the source account
269
- restore_location: Target location for restore (optional)
270
- restore_timestamp_in_utc: Restore point in UTC (optional)
271
272
Returns:
273
ItemPaged[RestorableTableResourcesGetResult]: Paginated list of restorable table resources
274
"""
275
276
def list_tables(
277
self,
278
location: str,
279
instance_id: str,
280
start_time: Optional[str] = None,
281
end_time: Optional[str] = None
282
) -> ItemPaged[RestorableTableGetResult]:
283
"""
284
List restorable tables for a specific account and time range.
285
286
Parameters:
287
- location: Location of the source account
288
- instance_id: Instance ID of the source account
289
- start_time: Start time for the restore range in UTC
290
- end_time: End time for the restore range in UTC
291
292
Returns:
293
ItemPaged[RestorableTableGetResult]: Paginated list of restorable tables
294
"""
295
```
296
297
## Usage Examples
298
299
### Discovering Restorable Accounts
300
301
```python
302
from azure.mgmt.cosmosdb import CosmosDBManagementClient
303
from azure.identity import DefaultAzureCredential
304
from datetime import datetime, timedelta
305
306
client = CosmosDBManagementClient(DefaultAzureCredential(), "subscription-id")
307
308
# List all restorable accounts in East US
309
restorable_accounts = client.restorable_database_accounts.list_by_location("East US")
310
311
for account in restorable_accounts:
312
print(f"Account: {account.account_name}")
313
print(f"Instance ID: {account.instance_id}")
314
print(f"Creation Time: {account.creation_time}")
315
print(f"Deletion Time: {account.deletion_time}")
316
print(f"API Type: {account.api_type}")
317
print("---")
318
```
319
320
### Finding Restorable Resources for a Specific Time
321
322
```python
323
from datetime import datetime, timezone
324
325
# Target restore time (24 hours ago)
326
restore_time = datetime.now(timezone.utc) - timedelta(hours=24)
327
restore_timestamp = restore_time.strftime("%Y-%m-%dT%H:%M:%SZ")
328
329
# Get instance ID from a restorable account
330
account_instance_id = "12345678-1234-1234-1234-123456789012"
331
location = "East US"
332
333
# Discover all restorable SQL resources at the target time
334
sql_resources = client.restorable_sql_resources.list(
335
location=location,
336
instance_id=account_instance_id,
337
restore_timestamp_in_utc=restore_timestamp
338
)
339
340
for resource in sql_resources:
341
print(f"Resource Type: {resource.resource.resource_type}")
342
print(f"Resource ID: {resource.resource.resource_id}")
343
print(f"Restore Parameters: {resource.resource.restore_parameters}")
344
print("---")
345
```
346
347
### Discovering Restorable Collections in a Time Range
348
349
```python
350
# Define time range for discovery (last 7 days)
351
end_time = datetime.now(timezone.utc)
352
start_time = end_time - timedelta(days=7)
353
354
start_timestamp = start_time.strftime("%Y-%m-%dT%H:%M:%SZ")
355
end_timestamp = end_time.strftime("%Y-%m-%dT%H:%M:%SZ")
356
357
# List restorable SQL containers in a specific database
358
database_rid = "dbs/products"
359
containers = client.restorable_sql_containers.list(
360
location=location,
361
instance_id=account_instance_id,
362
database_rid=database_rid,
363
start_time=start_timestamp,
364
end_time=end_timestamp
365
)
366
367
for container in containers:
368
print(f"Container: {container.resource.container_name}")
369
print(f"Operation Type: {container.resource.operation_type}")
370
print(f"Event Timestamp: {container.resource.event_timestamp}")
371
print(f"Owner ID: {container.resource.owner_id}")
372
print("---")
373
```
374
375
### Cross-Region Restore Discovery
376
377
```python
378
# Discover resources that can be restored to a different region
379
source_location = "East US"
380
target_location = "West US"
381
382
gremlin_resources = client.restorable_gremlin_resources.list(
383
location=source_location,
384
instance_id=account_instance_id,
385
restore_location=target_location,
386
restore_timestamp_in_utc=restore_timestamp
387
)
388
389
for resource in gremlin_resources:
390
print(f"Can restore {resource.resource.resource_type} to {target_location}")
391
print(f"Resource: {resource.resource.resource_id}")
392
print("---")
393
```
394
395
## Key Types
396
397
```python { .api }
398
class RestorableDatabaseAccountGetResult:
399
"""Information about a restorable database account."""
400
id: str
401
name: str
402
type: str
403
location: str
404
account_name: str # Original account name
405
instance_id: str # Unique identifier for the account instance
406
creation_time: str # Account creation time in UTC
407
deletion_time: str # Account deletion time in UTC (null if not deleted)
408
api_type: str # API type ("Sql", "MongoDB", "Cassandra", "Table", "Gremlin")
409
restorable_locations: List[RestorableLocationResource]
410
oldest_restorable_time: str # Oldest point-in-time that can be restored
411
412
class RestorableLocationResource:
413
"""Information about a restorable location."""
414
location_name: str # Azure region name
415
regional_database_account_instance_id: str # Regional instance identifier
416
creation_time: str # Regional account creation time
417
deletion_time: str # Regional account deletion time (null if not deleted)
418
419
class RestorableSqlResourcesGetResult:
420
"""Restorable SQL resources information."""
421
id: str
422
name: str
423
type: str
424
resource: RestorableSqlResourcesGetResultResource
425
426
class RestorableSqlResourcesGetResultResource:
427
"""Details of restorable SQL resources."""
428
database_name: str # Database name
429
collection_names: List[str] # List of container names
430
resource_type: str # Type of resource
431
resource_id: str # Resource identifier
432
restore_parameters: Dict[str, Any] # Parameters needed for restore
433
434
class RestorableSqlDatabaseGetResult:
435
"""Information about a restorable SQL database."""
436
id: str
437
name: str
438
type: str
439
resource: RestorableSqlDatabaseResource
440
441
class RestorableSqlDatabaseResource:
442
"""Details of a restorable SQL database."""
443
database_name: str # Name of the database
444
operation_type: str # Operation that created this restore point ("Create", "Delete", "Replace", "SystemOperation")
445
event_timestamp: str # Timestamp when the operation occurred
446
owner_id: str # Owner identifier
447
owner_resource_id: str # Owner resource identifier
448
449
class RestorableSqlContainerGetResult:
450
"""Information about a restorable SQL container."""
451
id: str
452
name: str
453
type: str
454
resource: RestorableSqlContainerResource
455
456
class RestorableSqlContainerResource:
457
"""Details of a restorable SQL container."""
458
container_name: str # Name of the container
459
operation_type: str # Operation that created this restore point
460
event_timestamp: str # Timestamp when the operation occurred
461
owner_id: str # Owner identifier
462
owner_resource_id: str # Owner resource identifier
463
464
class RestorableMongodbResourcesGetResult:
465
"""Restorable MongoDB resources information."""
466
id: str
467
name: str
468
type: str
469
resource: RestorableMongodbResourcesGetResultResource
470
471
class RestorableMongodbResourcesGetResultResource:
472
"""Details of restorable MongoDB resources."""
473
database_name: str # Database name
474
collection_names: List[str] # List of collection names
475
resource_type: str # Type of resource
476
resource_id: str # Resource identifier
477
restore_parameters: Dict[str, Any] # Parameters needed for restore
478
479
class RestorableMongodbDatabaseGetResult:
480
"""Information about a restorable MongoDB database."""
481
id: str
482
name: str
483
type: str
484
resource: RestorableMongodbDatabaseResource
485
486
class RestorableMongodbDatabaseResource:
487
"""Details of a restorable MongoDB database."""
488
database_name: str # Name of the database
489
operation_type: str # Operation that created this restore point
490
event_timestamp: str # Timestamp when the operation occurred
491
owner_id: str # Owner identifier
492
owner_resource_id: str # Owner resource identifier
493
494
class RestorableGremlinResourcesGetResult:
495
"""Restorable Gremlin resources information."""
496
id: str
497
name: str
498
type: str
499
resource: RestorableGremlinResourcesGetResultResource
500
501
class RestorableTableResourcesGetResult:
502
"""Restorable Table resources information."""
503
id: str
504
name: str
505
type: str
506
resource: RestorableTableResourcesGetResultResource
507
508
class RestorableTableResourcesGetResultResource:
509
"""Details of restorable Table resources."""
510
table_names: List[str] # List of table names
511
resource_type: str # Type of resource
512
resource_id: str # Resource identifier
513
restore_parameters: Dict[str, Any] # Parameters needed for restore
514
```