|
2 | 2 | title: Back up Azure Database for PostgreSQL with long-term-retention using Azure CLI
|
3 | 3 | description: Learn how to back up Azure Database for PostgreSQL using Azure CLI.
|
4 | 4 | ms.topic: conceptual
|
5 |
| -ms.date: 01/24/2022 |
| 5 | +ms.date: 02/25/2022 |
6 | 6 | ms.custom: devx-track-azurecli
|
7 | 7 | author: v-amallick
|
8 | 8 | ms.service: backup
|
@@ -318,132 +318,134 @@ az dataprotection backup-instance create --resource-group testBkpVaultRG --vault
|
318 | 318 |
|
319 | 319 | You have to specify a retention rule while you trigger backup. To view the retention rules in policy, navigate through the policy JSON file for retention rules. In the following example, there are two retention rules with names **Default** and **Monthly**. We'll use the **Monthly** rule for the on-demand backup.
|
320 | 320 |
|
321 |
| - ```azurecli |
322 |
| - az dataprotection backup-policy show -g ossdemorg --vault-name ossdemovault-1 --subscription e3d2d341-4ddb-4c5d-9121-69b7e719485e --name osspol5 |
323 |
| - { |
324 |
| - "id": "/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/resourceGroups/ossdemorg/providers/Microsoft.DataProtection/backupVaults/ossdemovault-1/backupPolicies/osspol5", |
325 |
| - "name": "osspol5", |
326 |
| - "properties": { |
327 |
| - "datasourceTypes": [ |
328 |
| - "Microsoft.DBforPostgreSQL/servers/databases" |
329 |
| - ], |
330 |
| - "objectType": "BackupPolicy", |
331 |
| - "policyRules": [ |
332 |
| - { |
333 |
| - "backupParameters": { |
334 |
| - "backupType": "Full", |
335 |
| - "objectType": "AzureBackupParams" |
336 |
| - }, |
337 |
| - "dataStore": { |
338 |
| - "dataStoreType": "VaultStore", |
339 |
| - "objectType": "DataStoreInfoBase" |
340 |
| - }, |
341 |
| - "name": "BackupWeekly", |
342 |
| - "objectType": "AzureBackupRule", |
343 |
| - "trigger": { |
344 |
| - "objectType": "ScheduleBasedTriggerContext", |
345 |
| - "schedule": { |
346 |
| - "repeatingTimeIntervals": [ |
347 |
| - "R/2020-04-04T20:00:00+00:00/P1W", |
348 |
| - "R/2020-04-01T20:00:00+00:00/P1W" |
349 |
| - ], |
350 |
| - "timeZone": "UTC" |
351 |
| - }, |
352 |
| - "taggingCriteria": [ |
| 321 | +```azurecli |
| 322 | +az dataprotection backup-policy show -g ossdemorg --vault-name ossdemovault-1 --subscription e3d2d341-4ddb-4c5d-9121-69b7e719485e --name osspol5 |
| 323 | +{ |
| 324 | + "id": "/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/resourceGroups/ossdemorg/providers/Microsoft.DataProtection/backupVaults/ossdemovault-1/backupPolicies/osspol5", |
| 325 | + "name": "osspol5", |
| 326 | + "properties": { |
| 327 | + "datasourceTypes": [ |
| 328 | + "Microsoft.DBforPostgreSQL/servers/databases" |
| 329 | + ], |
| 330 | + "objectType": "BackupPolicy", |
| 331 | + "policyRules": [ |
| 332 | + { |
| 333 | + "backupParameters": { |
| 334 | + "backupType": "Full", |
| 335 | + "objectType": "AzureBackupParams" |
| 336 | + }, |
| 337 | + "dataStore": { |
| 338 | + "dataStoreType": "VaultStore", |
| 339 | + "objectType": "DataStoreInfoBase" |
| 340 | + }, |
| 341 | + "name": "BackupWeekly", |
| 342 | + "objectType": "AzureBackupRule", |
| 343 | + "trigger": { |
| 344 | + "objectType": "ScheduleBasedTriggerContext", |
| 345 | + "schedule": { |
| 346 | + "repeatingTimeIntervals": [ |
| 347 | + "R/2020-04-04T20:00:00+00:00/P1W", |
| 348 | + "R/2020-04-01T20:00:00+00:00/P1W" |
| 349 | + ], |
| 350 | + "timeZone": "UTC" |
| 351 | + }, |
| 352 | + "taggingCriteria": [ |
| 353 | + { |
| 354 | + "criteria": [ |
353 | 355 | {
|
354 |
| - "criteria": [ |
355 |
| - { |
356 |
| - "absoluteCriteria": [ |
357 |
| - "FirstOfMonth" |
358 |
| - ], |
359 |
| - "daysOfMonth": null, |
360 |
| - "daysOfTheWeek": null, |
361 |
| - "monthsOfYear": null, |
362 |
| - "objectType": "ScheduleBasedBackupCriteria", |
363 |
| - "scheduleTimes": null, |
364 |
| - "weeksOfTheMonth": null |
365 |
| - } |
| 356 | + "absoluteCriteria": [ |
| 357 | + "FirstOfMonth" |
366 | 358 | ],
|
367 |
| - "isDefault": false, |
368 |
| - "tagInfo": { |
369 |
| - "eTag": null, |
370 |
| - "id": "Monthly_", |
371 |
| - "tagName": "Monthly" |
372 |
| - }, |
373 |
| - "taggingPriority": 15 |
374 |
| - }, |
375 |
| - { |
376 |
| - "criteria": null, |
377 |
| - "isDefault": true, |
378 |
| - "tagInfo": { |
379 |
| - "eTag": null, |
380 |
| - "id": "Default_", |
381 |
| - "tagName": "Default" |
382 |
| - }, |
383 |
| - "taggingPriority": 99 |
| 359 | + "daysOfMonth": null, |
| 360 | + "daysOfTheWeek": null, |
| 361 | + "monthsOfYear": null, |
| 362 | + "objectType": "ScheduleBasedBackupCriteria", |
| 363 | + "scheduleTimes": null, |
| 364 | + "weeksOfTheMonth": null |
384 | 365 | }
|
385 |
| - ] |
| 366 | + ], |
| 367 | + "isDefault": false, |
| 368 | + "tagInfo": { |
| 369 | + "eTag": null, |
| 370 | + "id": "Monthly_", |
| 371 | + "tagName": "Monthly" |
| 372 | + }, |
| 373 | + "taggingPriority": 15 |
| 374 | + }, |
| 375 | + { |
| 376 | + "criteria": null, |
| 377 | + "isDefault": true, |
| 378 | + "tagInfo": { |
| 379 | + "eTag": null, |
| 380 | + "id": "Default_", |
| 381 | + "tagName": "Default" |
| 382 | + }, |
| 383 | + "taggingPriority": 99 |
386 | 384 | }
|
387 |
| - }, |
388 |
| - { |
389 |
| - "isDefault": false, |
390 |
| - "lifecycles": [ |
391 |
| - { |
392 |
| - "deleteAfter": { |
393 |
| - "duration": "P10Y", |
394 |
| - "objectType": "AbsoluteDeleteOption" |
395 |
| - }, |
396 |
| - "sourceDataStore": { |
397 |
| - "dataStoreType": "VaultStore", |
398 |
| - "objectType": "DataStoreInfoBase" |
399 |
| - }, |
400 |
| - "targetDataStoreCopySettings": [] |
401 |
| - } |
402 |
| - ], |
403 |
| - "name": "Monthly", |
404 |
| - "objectType": "AzureRetentionRule" |
405 |
| - }, |
| 385 | + ] |
| 386 | + } |
| 387 | + }, |
| 388 | + { |
| 389 | + "isDefault": false, |
| 390 | + "lifecycles": [ |
406 | 391 | {
|
407 |
| - "isDefault": true, |
408 |
| - "lifecycles": [ |
409 |
| - { |
410 |
| - "deleteAfter": { |
411 |
| - "duration": "P1Y", |
412 |
| - "objectType": "AbsoluteDeleteOption" |
413 |
| - }, |
414 |
| - "sourceDataStore": { |
415 |
| - "dataStoreType": "VaultStore", |
416 |
| - "objectType": "DataStoreInfoBase" |
417 |
| - }, |
418 |
| - "targetDataStoreCopySettings": [] |
419 |
| - } |
420 |
| - ], |
421 |
| - "name": "Default", |
422 |
| - "objectType": "AzureRetentionRule" |
| 392 | + "deleteAfter": { |
| 393 | + "duration": "P10Y", |
| 394 | + "objectType": "AbsoluteDeleteOption" |
| 395 | + }, |
| 396 | + "sourceDataStore": { |
| 397 | + "dataStoreType": "VaultStore", |
| 398 | + "objectType": "DataStoreInfoBase" |
| 399 | + }, |
| 400 | + "targetDataStoreCopySettings": [] |
423 | 401 | }
|
424 |
| - ] |
| 402 | + ], |
| 403 | + "name": "Monthly", |
| 404 | + "objectType": "AzureRetentionRule" |
425 | 405 | },
|
426 |
| - "resourceGroup": "ossdemorg", |
427 |
| - "systemData": null, |
428 |
| - "type": "Microsoft.DataProtection/backupVaults/backupPolicies" |
429 |
| - } |
430 |
| - ``` |
| 406 | + { |
| 407 | + "isDefault": true, |
| 408 | + "lifecycles": [ |
| 409 | + { |
| 410 | + "deleteAfter": { |
| 411 | + "duration": "P1Y", |
| 412 | + "objectType": "AbsoluteDeleteOption" |
| 413 | + }, |
| 414 | + "sourceDataStore": { |
| 415 | + "dataStoreType": "VaultStore", |
| 416 | + "objectType": "DataStoreInfoBase" |
| 417 | + }, |
| 418 | + "targetDataStoreCopySettings": [] |
| 419 | + } |
| 420 | + ], |
| 421 | + "name": "Default", |
| 422 | + "objectType": "AzureRetentionRule" |
| 423 | + } |
| 424 | + ] |
| 425 | + }, |
| 426 | + "resourceGroup": "ossdemorg", |
| 427 | + "systemData": null, |
| 428 | + "type": "Microsoft.DataProtection/backupVaults/backupPolicies" |
| 429 | +} |
| 430 | +``` |
| 431 | + |
| 432 | +### Trigger an on-demand backup using command |
431 | 433 |
|
432 |
| -To trigger an on-demand backup, use the [az dataprotection backup-instance adhoc-backup](/cli/azure/dataprotection/backup-instance#az_dataprotection_backup_instance_adhoc_backup) command. |
| 434 | +Trigger an on-demand backup using the [az dataprotection backup-instance adhoc-backup](/cli/azure/dataprotection/backup-instance#az_dataprotection_backup_instance_adhoc_backup) command. |
433 | 435 |
|
434 |
| - ```azurecli |
435 |
| - az dataprotection backup-instance adhoc-backup --name "ossrg-empdb11" --rule-name "Monthly" --resource-group testBkpVaultRG --vault-name TestBkpVault |
436 |
| - ``` |
| 436 | +```azurecli |
| 437 | +az dataprotection backup-instance adhoc-backup --name "ossrg-empdb11" --rule-name "Monthly" --resource-group testBkpVaultRG --vault-name TestBkpVault |
| 438 | +``` |
437 | 439 |
|
438 | 440 | ## Track jobs
|
439 | 441 |
|
440 | 442 | Track all jobs using the [az dataprotection job list](/cli/azure/dataprotection/job#az_dataprotection_job_list) command. You can list all jobs and fetch a particular job detail.
|
441 | 443 |
|
442 | 444 | You can also use _Az.ResourceGraph_ to track all jobs across all Backup vaults. Use the [az dataprotection job list-from-resourcegraph](/cli/azure/dataprotection/job#az_dataprotection_job_list_from_resourcegraph) command to fetch the relevant jobs that are across Backup vaults.
|
443 | 445 |
|
444 |
| - ```azurecli |
445 |
| - az dataprotection job list-from-resourcegraph --datasource-type AzureDatabaseForPostgreSQL --status Completed |
446 |
| - ``` |
| 446 | +```azurecli |
| 447 | +az dataprotection job list-from-resourcegraph --datasource-type AzureDatabaseForPostgreSQL --status Completed |
| 448 | +``` |
447 | 449 |
|
448 | 450 | ## Next steps
|
449 | 451 |
|
|
0 commit comments