From b842e42f31b3fb544939c956511ac9a43680d379 Mon Sep 17 00:00:00 2001 From: Sambit Rath Date: Wed, 30 Dec 2020 13:51:27 +0530 Subject: [PATCH 1/3] Added default backup retention as 30 days --- src/azure-cli/azure/cli/command_modules/backup/custom.py | 2 ++ src/azure-cli/azure/cli/command_modules/backup/custom_afs.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom.py b/src/azure-cli/azure/cli/command_modules/backup/custom.py index 7a17eee7502..2391776d09d 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom.py @@ -376,6 +376,8 @@ def update_policy_for_item(cmd, client, resource_group_name, vault_name, item, p def backup_now(cmd, client, resource_group_name, vault_name, item, retain_until): + if retain_until is None: + retain_until = (datetime.utcnow() + timedelta(days=30)).strftime('%d-%m-%Y') # Get container and item URIs container_uri = _get_protection_container_uri_from_id(item.id) item_uri = _get_protected_item_uri_from_id(item.id) diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py b/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py index af92c7dcaae..1fd691152d0 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------------------------- import azure.cli.command_modules.backup.custom_help as helper +from datetime import datetime, timedelta # pylint: disable=import-error # pylint: disable=unused-argument @@ -85,6 +86,8 @@ def enable_for_AzureFileShare(cmd, client, resource_group_name, vault_name, afs_ def backup_now(cmd, client, resource_group_name, vault_name, item, retain_until): + if retain_until is None: + retain_until = (datetime.utcnow() + timedelta(days=30)).strftime('%d-%m-%Y') container_uri = helper.get_protection_container_uri_from_id(item.id) item_uri = helper.get_protected_item_uri_from_id(item.id) trigger_backup_request = _get_backup_request(retain_until) From a4bca0320e219804675bcb524028507521b58ec7 Mon Sep 17 00:00:00 2001 From: Sambit Rath Date: Wed, 30 Dec 2020 14:52:16 +0530 Subject: [PATCH 2/3] CLI style fix --- src/azure-cli/azure/cli/command_modules/backup/custom_afs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py b/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py index 1fd691152d0..0274fe33ca3 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom_afs.py @@ -2,9 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - -import azure.cli.command_modules.backup.custom_help as helper from datetime import datetime, timedelta +import azure.cli.command_modules.backup.custom_help as helper # pylint: disable=import-error # pylint: disable=unused-argument From 12bddfce6836d9b56fd0932937f2bc87db1c2ae7 Mon Sep 17 00:00:00 2001 From: Sambit Rath Date: Fri, 8 Jan 2021 10:21:39 +0530 Subject: [PATCH 3/3] Resolving comments --- src/azure-cli/azure/cli/command_modules/backup/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/backup/_params.py b/src/azure-cli/azure/cli/command_modules/backup/_params.py index 3cd669b5f41..a2669ea261c 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/_params.py +++ b/src/azure-cli/azure/cli/command_modules/backup/_params.py @@ -36,7 +36,7 @@ target_server_type_help = """Specify the type of the server which should be discovered.""" protectable_item_name_type_help = """Specify the resource name to be protected by Azure Backup service.""" backup_type_help = """'Full, Differential, Log, Copy-only-full' for backup Item type 'MSSQL'. 'Full, Differential' for backup item type 'SAPHANA'.""" -retain_until_help = """The date until which this backed up copy will be available for retrieval, in UTC (d-m-Y). For SAPHANA and SQL workload, retain-until parameter value will be overridden by the underlying policy.""" +retain_until_help = """The date until which this backed up copy will be available for retrieval, in UTC (d-m-Y). If not specified, 30 days will be taken as default value. For SAPHANA and SQL workload, retain-until parameter value will be overridden by the underlying policy.""" diskslist_help = """List of disks to be excluded or included.""" disk_list_setting_help = """option to decide whether to include or exclude the disk or reset any previous settings to default behavior""" target_container_name_help = """The target container to which the DB recovery point should be downloaded as files."""