我在SQL2012R2上收到此错误我在SQL2016上工作时没有什么
异常调用" SqlBackup"用" 1"参数:"备份失败 服务器' DEVSQLD01'。 "
脚本:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName
$dbName = "Staging-Xtra"
$timestamp = Get-Date -format yyyy-MM-dd-HHmmss
$targetPath = $backupDirectory + "\" + $dbName + "_" + $timestamp + ".bak"
$smoBackup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup")
$smoBackup.Action = "Database"
$smoBackup.BackupSetDescription = "Full Backup of " + $dbName
$smoBackup.BackupSetName = $dbName + " Backup"
$smoBackup.Database = $dbName
$smoBackup.MediaDescription = "Disk"
$smoBackup.Devices.AddDevice($targetPath, "File")
$smoBackup.SqlBackup($server)
异常调用" SqlBackup"用" 1"参数:"备份失败 服务器' DEVSQLD01'。 "
答案 0 :(得分:0)
我可能遇到了同样的问题。它与SQL Server服务帐户的目标文件夹的权限有关。
PowerShell只是将T-SQL提交给SQL Server来执行,因此运行该脚本的帐户必须具有必需的权限。一旦我给它读/写一切运行良好