question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error running SQL DB restore using AZ CLI

See original GitHub issue

This is autogenerated. Please review and update as needed.

Describe the bug

When running az backup restore restore-azurewl the error below occurs.

Initially I run az backup recoverypoint list to get a list of recovery points to work with. Then I run az backup recoveryconfig show to create a recovery config JSON file before running az backup restore restore-azurewl using the JSON file. The issue appears to be related to the JSON file but the formatting appears to be correct as the JSON file appears to validate.

Command Name az backup restore restore-azurewl

Errors:

The command failed with an unexpected error. Here is the traceback:
Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 718, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/_exception_handler.py", line 11, in backup_exception_handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_base.py", line 508, in restore_azure_wl
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_wl.py", line 618, in restore_azure_wl
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/backup/custom_help.py", line 448, in get_or_read_json
  File "json\__init__.py", line 293, in load
  File "json\__init__.py", line 346, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

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…

get list of recovery points to work with

  • az backup recoverypoint list --resource-group %resourcegroup% --vault-name %RSVVault% --container-name %container% --item-name “SQLDataBase;mssqlserver;pm” --output table

build recoveryconfig json file

  • az backup recoveryconfig show --restore-mode OriginalWorkloadRestore --backup-management-type AzureWorkload –container-name %container% --item-name "SQLDataBase;mssqlserver;pm" –log-point-in-time “27-09-2022-07:32:58” --resource-group %resourcegroup% –target-container-name %targetcontainer% --target-item-name "SQLDataBase;mssqlserver;pm" –target-resource-group %resourcegroup% --target-server-name %servername% –target-server-type SQLDatabase --target-vault-name %RSVVault% –vault-name %RSVVault% --workload-type SQLDataBase –output json `

c:\temp\recoveryconfig.json

run restore task

  • az backup restore restore-azurewl --resource-group {} --vault-name {} --recovery-config recoveryconfig.json

Expected Behavior

A restore job should be started in Azure RSV.

Environment Summary

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

azure-cli 2.40.0

Additional Context

I have been following the docs below; https://learn.microsoft.com/en-us/azure/backup/backup-azure-sql-restore-cli https://learn.microsoft.com/en-us/cli/azure/backup/recoveryconfig?view=azure-cli-latest https://learn.microsoft.com/en-us/cli/azure/backup/restore?view=azure-cli-latest#az-backup-restore-restore-azurewl

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SaurabhSharma-MSFTcommented, Sep 28, 2022

@robnotley We are looking into it and get back to you for any additional information.

0reactions
zubairabidcommented, Oct 21, 2022

@robnotley can you save the JSON output manually into a file instead of using the > c:\github\recovery.json bit, and try the request with that file instead? It appears to be an file encoding issue with the way Powershell < 6 behaves, and not a CLI bug. You can check https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding?view=powershell-7#configuring-powershell for more details if the workaround works for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restore a database from a backup - Azure SQL Database
To restore a database by using the Azure CLI, see az sql db restore. Gets one or more databases. Gets a geo-redundant backup...
Read more >
Working with Azure SQL databases using Azure CLI 2.0
The basic command to back up an SQL Database is “az sql db export” and to restore the database we can use “az...
Read more >
Azure CLI list Azure SQL Server DB backups - Server Fault
Answering my own question: Azure CLI does not seem to have this feature implemented. Can use Powershell for this. Automation possible with ......
Read more >
Troubleshooting for Amazon RDS - AWS Documentation
Troubleshoot problems you have with DB instances. ... the DB instance password by using the Amazon RDS console, the AWS CLI command modify-db-instance, ......
Read more >
Backup and Restore a SQL Database with the Azure CLI
Performing the Database Backup. Now we've gathered all the necessary information, we can perform the backup with a single az sql db export ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found