如何使用 dbatools powershell 将 SQL 服务器实例从本地实例迁移到 Azure VM SQL 服务器实例?

How to migrate SQL Server Instance from Local Instance to Azure VM SQL Server Instance using dbatools powershell?

如何将 SQL 服务器实例从本地实例迁移到 Azure VM SQL 服务器实例?

求高手支持解决以下问题

场景:

本地实例:SQLSRV01

Azure 虚拟机:23.96.20.20

-本地 SQL SERVER 和 Azure VM SQL SERVER 实例属于 SQLSERVER 2017 (14.0)

-为 sql 服务器

添加了入站端口规则

-可从双方访问的 SharedPath(本地计算机以及 Azure VM:23.96.20.20)

-DBSERVER17 实例可从本地计算机访问和连接

-相同的命令在我的本地计算机上运行良好,有两个不同的 SQL 服务器实例。

功率Shell脚本:

 $params = @{
 Source = "SQLSRV01"
 Destination = "23.96.20.20"
 SharedPath = "Z:"
 BackupRestore = $true
 }
  Start-DbaMigration @params -Force | Select * | Out-GridView

收到输出:

PS C:\WINDOWS\system32> E:\PowerShellScripts\RemoteInstance.ps1
WARNING: [16:05:58][Copy-DbaSpConfigure] Error occurred while establishing connection to 23.96.20.20 | The wait operat
ion timed out
WARNING: [16:06:15][Copy-DbaCustomError] Error occurred while establishing connection to 23.96.20.20 | The wait operat
ion timed out
WARNING: [16:06:15][Copy-DbaCredential] Console not elevated, but elevation is required to perform some actions on loc
alhost for this command.
WARNING: [16:06:15][Copy-DbaDbMail] Error occurred while establishing connection to 23.96.20.20 | The wait operation t
imed out
WARNING: [16:06:15][Copy-DbaRegServer] Error occurred while establishing connection to 23.96.20.20 | The wait operatio
n timed out
WARNING: [16:06:15][Copy-DbaBackupDevice] Error occurred while establishing connection to 23.96.20.20 | The wait opera
tion timed out
WARNING: [16:06:15][Copy-DbaInstanceTrigger] Error occurred while establishing connection to 23.96.20.20 | The wait op
eration timed out
WARNING: [16:06:15][Copy-DbaDatabase] Error occurred while establishing connection to 23.96.20.20 | The wait operation
 timed out
WARNING: [16:06:15][Copy-DbaLogin] Error occurred while establishing connection to 23.96.20.20 | The wait operation ti
med out
The wait operation timed out
At C:\Program Files\WindowsPowerShell\Modules\dbatools.0.113\allcommands.ps1:83435 char:9
         throw $records[0]
         ~~~~~~~~~~~~~~~~~
     CategoryInfo          : NotSpecified: (:) [], Exception
     FullyQualifiedErrorId : dbatools_Connect-DbaInstance

提供的参数 $scred、$dcred 然后将 $scred 对象传递给 SourceSqlCredential,并将 $dcred 对象传递给 DestinationSqlCredential。

  $scred = Get-Credential
  $dcred = Get-Credential
  $params = @{
  Source = "SQLSRV01"
  Destination = "23.96.20.20"
  SourceSqlCredential = $scred
  DestinationSqlCredential =$dcred
  SharedPath = "\SharedDB"
  BackupRestore = $true
  }
   Start-DbaMigration @params -Force | Select * | Out-GridView