简体   繁体   English

使用 PowerShell 在 Azure 中恢复托管的 SQL 实例

[英]Restoring a managed SQL instance in Azure using PowerShell

I am trying to figure out how to restore a database from one managed SQL instance to another.我试图弄清楚如何将数据库从一个托管的 SQL 实例还原到另一个实例。 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:这是 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;这是 Azure 文档的复制粘贴; so I'm not sure what I'm doing wrong.所以我不确定我做错了什么。 Any help would be appreciated.任何帮助,将不胜感激。

As mentioned in the comment, you need to pass the PointInTime as a DateTime instead of String , you could specify the 4/7/2020 12:00:00 as below.如评论中所述,您需要将PointInTime作为DateTime而不是String传递,您可以指定4/7/2020 12:00:00如下所示。

Sample:样本:

$PointInTime = Get-Date -Year 2020 -Month 4 -Day 7 -Hour 12 -Minute 0 -Second 0
Restore-AzSqlInstanceDatabase `
    -Name "SomeDatabase" `
    -InstanceName "our-oltp-dev" `
    -ResourceGroupName "dev-managedsqlinstances" `
    -PointInTime $PointInTime `
    -TargetInstanceDatabaseName "SomeDatabase_FROM_DEV" `
    -TargetInstanceName "our-oltp-sandbox" `
    -TargetResourceGroupName "sandbox-managedsqlinstances"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM