How do i delete MARS generated backup items in Recovery Vault - azure

I'm trying to delete recovery vault but it has some old data generated by MARS agents on non-existent machines. There is no UI option to delete those.
I tried Powershell below but it fails with Get-AzureRmRecoveryServicesBackupItem : BackupManagementType is not expected for WorkloadType: AzureVM
Not sure what am I doing wrong
PS Azure:\> Get-AzureRmRecoveryServicesBackupContainer -ContainerType Windows -Status Registered -BackupManagementType MARS
Name ContainerType BackupManagementType
---- ------------- --------------------
tencapsql01. Windows MARS
tencapweb1. Windows MARS
Azure:\converted to MS-AZR-0003P sub
PS Azure:\> $containers = Get-AzureRmRecoveryServicesBackupContainer -ContainerType Windows -Status Registered -BackupManagementType MARS
Azure:\converted to MS-AZR-0003P sub
PS Azure:\> Get-AzureRmRecoveryServicesBackupItem -Container $containers[0] -WorkloadType AzureVM
Get-AzureRmRecoveryServicesBackupItem : BackupManagementType is not expected for WorkloadType: AzureVM
At line:1 char:1
+ Get-AzureRmRecoveryServicesBackupItem -Container $containers[0] -Work ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzureRmRecoveryServicesBackupItem], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupItem

Deleting the backup related to MARS agent is a two step process in Azure Portal.
In step one, you need to go to Recovery Service vault -> Backup items -> Select
Backup Items (Azure Backup Agent) -> Select your backed up machine.
Now, you won't see the usual delete or stop backup options here like you see while deleting an Azure Virtual Machine. Instead, you need to select the "Computer name" option on this screen and that will give you an option to delete. Follow the usual prompt to delete. Note that I saw two unusual things here while deleting. One, there was a dot at the end of my backed up machine name and I had to make sure to use the dot when Azure asks me to input the name of item to be deleted before deleting the item. Second was hitting delete didn't give any success or failure message. I believe this might be because my backed up machine was shut down or disconnected (I do have not access to it right now).
In step two, you need to go to Recovery Service Vault -> Backup Infrastructure -> PROTECTED SERVERS -> Protected Servers (Azure Backup Agent) -> Select your backed up machine.
This should give you another delete option on the resulting screen and that completes the deletion process.
Let me know if this helps. I can look further if you need Powershell options as well.

Deleting backup data does not remove the retention points you may have kept so, not having any items being actively backed up but still have some GRS data is possible to have.
If you want to force delete regardless of contents, try - The PowerShell cmdlet to delete a recovery vault is “Remove-AzureRmRecoveryServicesVault -Vault ”. To get the vault object using Get-AzureRmRecoveryServicesVault.
Caution: Using the “Remove-AzureRmRecoveryServicesVault” cmdlet will delete the vault irrespective of the contents of the vault. So if there are replicating machines or backed up machines etc. in the vault, these will be lost.
Additionally if there were on-premises assets that were registered to the vault, these would need to be manually cleaned up because clean up cannot be triggered from the vault once it has been deleted.

Before you could delete the RS vault, Ensure all backup job are stopped and There are no items under Backup Management Servere(BMS)/ Protected Servers.
If you have any items left there, delete the BMS/Protected Servers associated and then you will be able to delete RS vault.
I have tried it. It works for sure!
All the Best!

To delete a MARS generated (Azure Backup agent) recovery point in a Recovery Services, vault you can perform the following in the Azure Web Portal UI:
In the vault dashboard menu, scroll down to the Manage section, and click Backup Infrastructure.
In the sub-menu, click Protected Servers to view the list of protected server types, including Azure Backup agent.
In the Protected Servers list, click Azure Backup Agent.
In the list of servers, click one to open its menu.
On the selected server's dashboard menu, click Delete.
For a more detailed description of the steps above, see: https://learn.microsoft.com/en-us/azure/backup/backup-azure-delete-vault#removing-azure-backup-agent-recovery-points

Related

How do I delete an sql database in Azure?

I have used the following powershell script to delete a database:
Remove-AzureRmSqlDatabase -ServerName $server -ResourceGroupName $rgname -DatabaseName $dbname
(first setting the variables)
and have tried using the Azure Portal
The port indicates a success in deletion, as does the activity logs, however
the resource is not being deleted?
Screenshot of activity log:
The deletes (on a number of occasions after the db comes back) show successful, however there is an audit policy that seems to be doing something.
There are no Locks on the resrouce group.
UPDATE:
I have deleted from SSMS, and is not showing there or in the portal anymore..
(will wait to see if it comes back, as it did when deleting via portal and powershell)
UPDATE 2:
Database is now back, so this is the database having been deleted 3 ways, portal, powershell and via SSMS.
It turns out the web application uses EF migrations which is recreating the database.
Note: The bigger issue is that the database is created on a much higher, and much more expensive tier.
Do you happen to have a rogue policy somewhere? It seems something is running a Policy Effect: deployIfNotExist on the resource. Without access to your environment, there's not much I could recommend.
Check the documentation here: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/effects#audit

Change Azure Resource Group with a backup attached

I'm trying to move a disk from a resource group to another one(with the same region) and I get an error telling me it's attached to a Azure Backup job. "Resource X are being backed up as part of a Azure Backup job"
The backup is set in a Recovery Vault.
I tried to stop the backup and delete the data in it (it's a dev environment) and I still get this error.
Is there something I am missing?
Thanks,

Azure back up unable to delete backup items

I used the Azure Backup client (MARS) to back up a server he had. The server no longer exists. In the Azure portal I am unable to delete the vault because the resource group contains backup items.
I tried using Powershell but Az.RecoveryServices is not meant to be used for MARS BackupManagementType. You can Get-AzureRmRecoveryServicesBackupContainer but then Get-AzureRmRecoveryServicesBackupItem fails because there is no WorkLoadType for MARS
So I cant delete the backup items from the Portal. I cant delete backup Items using powershell and the server no longer exists so I can use the MARS agent to delete items.
You can't delete a Recovery Services vault that has servers registered in it, or that holds backup data.
To gracefully delete a vault, unregister servers it contains, remove vault data, and then delete the vault.
If you try to delete a vault that still has dependencies, an error message is issued, and you will need to manually remove the vault dependencies, including:
Backed up items
Protected servers
Backup management servers (Azure Backup Server, DPM)
Refer to this article for detailed info:https://learn.microsoft.com/en-us/azure/backup/backup-azure-delete-vault
Note: You can use Cloud Shell available in portal to achieve this. Please select PowerShell after you launch Cloud Shell.
Kindly let us know if the above helps or you need further assistance on this issue.

Azure: Is it possible to delete a restore point in azure backup?

I have a test restore point (it's older than 30 days) I wanted to delete to save on the cost. I tried via azure portal the only option I found is to delete the backup data, not the restore point of a particular vm.
I'm currently using classic deployment and the VMs are deployed using classic deployment.
Now it is possible thought portal, powershell and CLI.
First of all you need to stop backup (retain backup).
Disable soft delete in RSV properties.
After that find appropriate RG - AzureBackupRG-location_of_vm, example: AzureBackupRG_westus2_1 Remember to check "Show hidden types" in RG.
Last step is to delete restore points in this RG. You only delete restore point, not backup from vault
*
*PORTAL**:
Temporarily stop the backup and retain backup data.
To move virtual machines configured with Azure Backup, do the following steps:
Find the location of your virtual machine.
Find a resource group with the following naming pattern: AzureBackupRG_<location of your VM>_1. For example, AzureBackupRG_westus2_1
In the Azure portal, check Show hidden types.
Find the resource with type Microsoft.Compute/restorePointCollections that has the naming pattern AzureBackup_<name of your VM that you're trying to move>_###########.
Delete this resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
After the delete operation is complete, you can move your virtual machine.
Move the VM to the target resource group.
Resume the backup.
Link to MS Doc
As for as I know, It's impossible to delete a restore point in Azure backup. According to delete backup date in the official doc.
Unlike the process for restoring recovery points, when you delete
backup data, you can't choose specific recovery points to delete. If
you delete your backup data, you delete all associated recovery
points.
Moreover, It's not necessary to select specific recovery points to delete as you could customize retention range in backup policy. The Retention means how long data needs to be stored. Refer to this.
I got an 'internal system error' while trying to delete the restore point. This was because the VM had already been deallocated. I turned it back on, then was able the delete the restore point successfully, then shut the VM down again.

Azure delete backup vault fails with 'associated container'

I am cleaning out some old items from my azure account and cannot remove an older version Bacup Vault.
I get the following error when I try to delete it:
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 : COMPUTER-NAME. Unregister all containers from the vault and then
retry to delete vault
Notice the COMPUTER-NAME
That is the name of my computer, but I can not find the Azure back up agent installed on that computer. I also cannot find the computer name container in any storage containers in my entire azure account.
Can someone help me figure out how to remove these items
thanks in advance
First screenshot shows the Backup vault and the error message I get when I try to delete.
the second screenshot shows the BackupItems that remain, but I cannot delete them.
the red boxes cover my COMPUTER-NAME
Looks like my previous answer was turned into a comment due to brevity. Here's an update to make it a better answer anyway. Answer from that link quoted below for reference.
I have not mapped this answer to the corresponding Azure commands, but I was able to find my way to a solution via the Azure Portal. The steps were as follows:
Selected my Recovery Service resource
Under the Manage section, clicked Backup Infrastructure
Under Management Servers, clicked Protected Servers
In the list that followed, clicked on the row where my Protected Server > Count was greater than 0, in my case, Azure Backup Agent (because the backup agent was installed on my Windows Desktop)
Clicked on my server name in the Protected Server list
Clicked Delete in the card for my protected server
After that completed, I was able to delete the entire vault. These steps may be helpful if you have other Backup Infrastructure resources and possibly even Site Recovery Infrastructure resources associated with a vault.
Update: It seems like there's an open issue for Get-AzureRmRecoveryServicesBackupItem not having any capacity to return MARS backup items which is ultimately what the issue here was.

Resources