Skip to content

Instantly share code, notes, and snippets.

@BelRarr
Created September 3, 2019 15:38
Show Gist options
  • Save BelRarr/62429fde4371a39a9a7bb982d419393e to your computer and use it in GitHub Desktop.
Save BelRarr/62429fde4371a39a9a7bb982d419393e to your computer and use it in GitHub Desktop.
Configurer le Backup retention pour SQL Database
# 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