Error running SQL DB restore using AZ CLI
See original GitHub issueThis 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:
- Created a year ago
- Reactions:1
- Comments:11 (2 by maintainers)
Top GitHub Comments
@robnotley We are looking into it and get back to you for any additional information.
@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.