0

I am trying to figure out how to restore a database from one managed SQL instance to another. I'm following the tutorials, but I keep running into inscrutable error messages.

Here's my command:

Restore-AzSqlInstanceDatabase `
    -Name "SomeDatabase" `
    -InstanceName "our-oltp-dev" `
    -ResourceGroupName "dev-managedsqlinstances" `
    -PointInTime "4/7/2020 12:00:00" `
    -TargetInstanceDatabaseName "SomeDatabase_FROM_DEV" `
    -TargetInstanceName "our-oltp-sandbox" `
    -TargetResourceGroupName "sandbox-managedsqlinstances"

Here's the output:

PS C:\WINDOWS\system32> Restore-AzSqlInstanceDatabase `
    -Name "SomeDatabase" `
    -InstanceName "our-oltp-dev" `
    -ResourceGroupName "dev-managedsqlinstances" `
    -PointInTime "4/7/2020 12:00:00" `
    -TargetInstanceDatabaseName "SomeDatabase_FROM_DEV" `
    -TargetInstanceName "our-oltp-sandbox" `
    -TargetResourceGroupName "sandbox-managedsqlinstances"
Restore-AzSqlInstanceDatabase : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Restore-AzSqlInstanceDatabase `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Restore-AzSqlInstanceDatabase], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Azure.Commands.Sql.ManagedDatabase.Cmdlet.RestoreAzureRmSqlManagedDatabase

It's a copy-and-paste from the Azure docs; so I'm not sure what I'm doing wrong. Any help would be appreciated.

1 Answer 1

0

This command is somehow not clear for PowerShell and there is problem to determine which version of the method is accurate.

However it should work if you specify -FromPointInTimeBackup switch, I have checked it and got credentials error which is fine as I am not logged in to proper account.

PS C:\WINDOWS\system32> Restore-AzSqlInstanceDatabase `
>>     -Name "SomeDatabase" `
>>     -InstanceName "our-oltp-dev" `
>>     -ResourceGroupName "dev-managedsqlinstances" `
>>     -PointInTime "4/7/2020 12:00:00" `
>>     -TargetInstanceDatabaseName "SomeDatabase_FROM_DEV" `
>>     -TargetInstanceName "our-oltp-sandbox" `
>>     -TargetResourceGroupName "sandbox-managedsqlinstances" `
>>     -FromPointInTimeBackup
Restore-AzSqlInstanceDatabase : Your Azure credentials have not been set up or have expired, please run
Connect-AzAccount to set up your Azure credentials.
At line:1 char:1
+ Restore-AzSqlInstanceDatabase `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Restore-AzSqlInstanceDatabase], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ManagedDatabase.Cmdlet.RestoreAzureRmSqlManagedDatabase

Additionaly, be sure that you use the latest version of Az.Sql module.

Update-Module -Name Az.Sql -Force
1
  • My script has an explicit note in it that the format must be "yyyy-MM-ddTHH:mm:ss.fffZ", past self didn't clarify on why, just a note that it was required, so I have this when I restore databases between MI's... (([datetime](Get-Date)).ToUniversalTime()).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") Commented Aug 14, 2024 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.