gpt4 book ai didi

powershell - 如何删除azure sql db的长期保留并删除保管库

转载 作者:行者123 更新时间:2023-12-03 01:44:34 25 4
gpt4 key购买 nike

我正在尝试删除测试数据库上的长期保留策略并删除附加到它的保管库。我能够禁用该策略,但当我尝试删除保管库时,出现错误:

Vault cannot be deleted as there are existing resources within the vault. Please ensure there are no backup items, protected servers or backup management servers associated with this vault. Unregister the following containers associated with this vault before proceeding for deletion : Sql;mydatabase123;mysqlserver123-svr Unregister all containers from the vault and then retry to delete vault

我想完全解除他们的绑定(bind),这样我就可以与另一个保管库设置另一个长期策略,并测试我可以使用 azure sql 和保管库执行的操作的限制。

知道如何撤消我所做的事情吗?谢谢!

附注我发现这个问题也提出了here但没有解决方案。

最佳答案

保管库中有 SQL 备份。您需要找到 SQL 备份并将其删除。尝试以下脚本。

$vault = Get-AzureRmRecoveryServicesVault -Name "VaultName"

Set-AzureRmRecoveryServicesVaultContext -Vault $vault

#VIEW THE BACKUP ITEMS
$container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $vault.Name

$item = Get-AzureRmRecoveryServicesBackupItem -Container $container -WorkloadType AzureSQLDatabase

$availableBackups = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $item

$availableBackups
#REMOVE THE BACKUP ITEMS AND VAULT
$containers = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $vault.Name

ForEach ($container in $containers)
{
$items = Get-AzureRmRecoveryServicesBackupItem -container $container -WorkloadType AzureSQLDatabase

ForEach ($item in $items)
{
Disable-AzureRmRecoveryServicesBackupProtection -item $item -RemoveRecoveryPoints -ea SilentlyContinue
}

Unregister-AzureRmRecoveryServicesBackupContainer -Container $container
}

Remove-AzureRmRecoveryServicesVault -Vault $vault

您还可以查看此 question .

关于powershell - 如何删除azure sql db的长期保留并删除保管库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48714522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com