Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecoveryServicesBackup - possible to disable (and retain) backups of VM #1331

Closed
ecgg opened this issue Jul 28, 2017 · 5 comments
Closed

RecoveryServicesBackup - possible to disable (and retain) backups of VM #1331

ecgg opened this issue Jul 28, 2017 · 5 comments
Labels
ARM question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@ecgg
Copy link

ecgg commented Jul 28, 2017

Hi,

I'm not seeing a method to disable and retain backups for a VM in RecoveryServicesBackup - Backup​Protected​Items​Operations. Is this foreseen or is it already there in another method with custom headers?

@lmazuel
Copy link
Member

lmazuel commented Jul 28, 2017

@DheerendraRathor can you help here for this question? Thanks!

@lmazuel lmazuel added ARM question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 28, 2017
@DheerendraRathor
Copy link
Contributor

@ecgg Please use method create_or_update in protected_items_operations.py. In parameters you need to set protection_state = ProtectionState.ProtectionStopped.

Use class AzureIaaSComputeVMProtectedItem or AzureIaaSClassicComputeVMProtectedItem depending on type of VM you're working with.

@ecgg
Copy link
Author

ecgg commented Jul 31, 2017

@DheerendraRathor

So I'd do something like:

vm_name = ""ecazjump1
vm_group = "ecaz_infra"
bkp_rg = "ecaz_backup"
bkp_pol = "DefaultPolicy"
bkp_fab = "backupFabrics"


container_name = "iaasvmcontainer;" + vm_name
vm_in_bkp_name = "vm;iaasvmcontainerv2;" + vm_group + ";" + vm_name

pir = ProtectedItemResource(properties = AzureIaaSComputeVMProtectedItem(protection_state=ProtectionState.protection_stopped))

response = recovery_client.protected_items.create_or_update(bkp_vlt, bkp_rg, bkp_fab, container_name, vm_in_bkp_name, pir)

Except that gives me a

msrestazure.azure_exceptions.CloudError: Azure Error: BMSUserErrorDataSourceObjectNotFound
Message: Item not found.
Selected item might have been deleted. Please check if item is registered to the vault.

although the item is in the vault

@DheerendraRathor
Copy link
Contributor

Here is the snippet:

        protected_item_resource = ProtectedItemResource(
            properties=AzureIaaSComputeVMProtectedItem(source_resource_id=protected_item.virtual_machine_id,
                                                       protection_state=ProtectionState.protection_stopped,
                                                       )
        )

        response = self.client.protected_items.create_or_update(
            self.vault_name, self.resource_group, self.fabric_name, container_name, protected_item_name,
            protected_item_resource, raw=True
        )

container_name is "iaasvmcontainer;iaasvmcontainerv2;{vm_group};{vm_name}".

To get virtual_machine_id, do a list protected item and then use an element from that as protected_item.

protected_items = self.client.backup_protected_items.list(self.vault_name, self.resource_group)
protected_item = next(protected_item for protected_item in protected_items
                              if protected_item.name.lower() == vm_in_bkp_name .lower()).properties

@ecgg
Copy link
Author

ecgg commented Jul 31, 2017

@DheerendraRathor

That worked beautifully - thank you!

@ecgg ecgg closed this as completed Jul 31, 2017
@bsiegel bsiegel added the Service Attention Workflow: This issue is responsible by Azure service team. label Sep 26, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARM question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants