Created
September 3, 2019 15:38
-
-
Save BelRarr/62429fde4371a39a9a7bb982d419393e to your computer and use it in GitHub Desktop.
Configurer le Backup retention pour SQL Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# déclaration des variables | |
$SubscriptionId = "bd......3c" | |
$Location = "canadacentral" | |
clear-host | |
# connexion à Azure et positionnement sur la bonne souscription | |
Connect-AzureRmAccount | |
Set-AzureRmContext -Subscription $SubscriptionId | |
$resourceGroup = "bd-dev-canadacentral-rg" | |
$serverName = "mysqlserverdev" | |
$dbName = "mydb" | |
# get the server | |
$server = Get-AzSqlServer -ServerName $serverName -ResourceGroupName $resourceGroup | |
# create LTR policy with WeeklyRetention = 12 weeks and MonthlyRetention = 6 months. YearlyRetention = 0 by default. | |
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName -ResourceGroupName $resourceGroup -WeeklyRetention P12W -MonthlyRetention P6M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment