azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

backup-now 'item not found'

Open kiweezi opened this issue 2 years ago • 12 comments

This is autogenerated. Please review and update as needed.

Describe the bug

When running az backup protection backup-now for sql in azure vm, the backup item cannot be found, despite the container existing with protectable items listed.

This did work in the past, with almost identical code. Trying this code again, yields the same result.

Command Name az backup protection backup-now

Errors: Azure CLI

(BMSUserErrorDataSourceObjectNotFound) Item not found. Selected item might have been deleted. Please check if item is registered to the vault.
Code: BMSUserErrorDataSourceObjectNotFound
Message: Item not found. Selected item might have been deleted. Please check if item is registered to the vault.

Finding the error in the GUI, it shows this:

Error Code
CloudInternalError

Error Code
Microsoft Azure Backup encountered an internal error.

Recommended action
Wait for a few minutes and then try the operation again. If the issue persists, please contact Microsoft support.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here...
  • az backup protection backup-now --container-name {} --item-name {} --resource-group {} --vault-name {} --backup-management-type {} --backup-type {}

Expected Behavior

The SQL database in the Azure VM, in the backup container's protectable item list, is backed up once.

Environment Summary

Windows-10-10.0.22000-SP0
Python 3.10.5
Installer: MSI

azure-cli 2.38.0

Additional Context

This seemed to stop working around the time we started deploying similar environments in the same subscription, though they each have their own resource group and recovery vault. I don't think this is related, but it's all I can think of.

kiweezi avatar Jul 28 '22 11:07 kiweezi

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Jul 28 '22 13:07 ghost

route to CXP team

yonzhan avatar Jul 28 '22 13:07 yonzhan

@kiweezi I am not able to reproduce this in my environment and backup-now works fine. Can you please make sure that you are passing the correct backup item name? Also, validate the item name on Azure portal > Backup items.

SaurabhSharma-MSFT avatar Jul 28 '22 23:07 SaurabhSharma-MSFT

@kiweezi I am not able to reproduce this in my environment and backup-now works fine. Can you please make sure that you are passing the correct backup item name? Also, validate the item name on Azure portal > Backup items.

@SaurabhSharma-MSFT Thanks for the response! The items are not currently backed up yet, as they are SQLDataBase type. Therefore I cannot see them in the portal. I have created a backup container of the SQL in Azure VM and run protectable-item list to obtain the item name:

az backup protectable-item list
"name": "sqldatabase;mssqlserver;temp",

I've tried many variations of this name; mssqlserver;temp, temp, sqldatabase;temp, sqldatabase;mssqlserver. All fail with Item not found. Please provide a valid item_name. except the output from above, which fails with the error provided in the issue:

--item-name 'sqldatabase;mssqlserver;temp'

Message: Item not found. Selected item might have been deleted. Please check if item is registered to the vault.

I'll be honest and say I'm not sure what the item name is meant to be, when reading the docs, it doesn't explain where to get it. I just assumed it was that output from the protectable item list command above. I will say though that I'm 99% sure this command has worked for me before in the past, only now it is failing.

Does this make sense? Happy to provide any more in info :).

kiweezi avatar Jul 29 '22 07:07 kiweezi

@kiweezi Thanks for sharing details. You need to use "Friendly Name" instead of "Name" attribute retrieved by using az backup protectable-item list cmdlet.

SaurabhSharma-MSFT avatar Jul 29 '22 19:07 SaurabhSharma-MSFT

@kiweezi Thanks for sharing details. You need to use "Friendly Name" instead of "Name" attribute retrieved by using az backup protectable-item list cmdlet.

Hey @SaurabhSharma-MSFT, I appreciate the help :). I tried 'friendlyName' as you said and got a similar error message, but not quite the same.

Running protectable-item list I get the following info:

az backup protectable-item list
"name": "sqldatabase;mssqlserver;temp",
"properties": {
  "friendlyName": "Temp",
}

Taking the 'friendlyName' property as an item name for backup-now:

az backup protection backup-now --item-name 'Temp'
Item not found. Please provide a valid item_name.

I remember this leading to my initial confusion! If I can't gather the item name from the protectable item list, how am I supposed to script this process?

kiweezi avatar Aug 01 '22 13:08 kiweezi

@kiweezi I do not see any issues using name as "sqldatabase;mssqlserver;model". I believe, you are getting this error you have not enable backup for the required resource.
image Instead of using protectable-item list, please use az backup item list to get the list of backup items already protected or backed up to an Azure Recovery Services vault. protectable-item list gives you the list of items which are registered but yet to be protected.

SaurabhSharma-MSFT avatar Aug 09 '22 22:08 SaurabhSharma-MSFT

Hey @SaurabhSharma-MSFT. My apologies for the late reply!

Before I attempted the backup-now I used az backup protection auto-enable-for-azurewl. As I understand, this enables a backup policy for all databases on the SQL instance. Is there something else I have to do before I can use backup-now?

What commands did you use to prepare your environment for the backup-now command?

kiweezi avatar Aug 16 '22 13:08 kiweezi

Hey @SaurabhSharma-MSFT. Would you be able to share anymore about how you prepared your environment before you ran the backup-now command?

kiweezi avatar Sep 05 '22 11:09 kiweezi

@kiweezi Sorry for the delay. Can you please check this documentation - Back up SQL databases in Azure VM using Azure CLI.

SaurabhSharma-MSFT avatar Sep 06 '22 22:09 SaurabhSharma-MSFT

@kiweezi Sorry for the delay. Can you please check this documentation - Back up SQL databases in Azure VM using Azure CLI.

Thanks @SaurabhSharma-MSFT! I believe this guide wasn't available before I created this issue. I can already spot something different that I'm not doing from the guide. I will have a look at this in the next few days and see if I can replicate what you did to get this working.

kiweezi avatar Sep 07 '22 09:09 kiweezi

@kiweezi Please let me know if you have any other questions, else we are proceeding with the closure of this issue.

SaurabhSharma-MSFT avatar Sep 21 '22 00:09 SaurabhSharma-MSFT

@kiweezi We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.

SaurabhSharma-MSFT avatar Oct 03 '22 19:10 SaurabhSharma-MSFT