Author Posts

April 9, 2014 at 2:07 am

I have a script which looks like the following:-

$machine = $computerName
$server = New-Object Microsoft.SqlServer.Management.Smo.Server("$machine")

Write-Host "server = $($server)"

$backup = New-Object Microsoft.SqlServer.Management.Smo.Backup
$backup.Database = $databaseName

$date = Get-Date
$date = $date -replace "/", "-"
$date = $date -replace ":", "-"
$date = $date -replace " ", "_"

#$file = $backupFolderDBName + "\" + $databaseName + "_" + $date + ".bak"
$file = "c:\downloads\backup\test_1.bak"

$backup.Devices.AddDevice($file, [Microsoft.SqlServer.Management.Smo.DeviceType]::File)
$backup.Action = [Microsoft.SqlServer.Management.Smo.BackupActionType]::Database
$backup.SqlBackup($server)

We have a test environment, staging and production, on the test and staging environment SQL Server runs as Local System account – I can remote onto both these servers and backup all my databases as required. On Production SQL Server runs as a specified account, when my script hits the last line to do the actual backup I get the following error:-

SqlBackup" with "1" argument(s): "Backup failed for Server

Is this the double hop issue, if I log onto the production server and run my script on the box itself it works just fine.

Thanks for any advice
Greg

April 10, 2014 at 2:50 am

So long as you're not asking the remoting session to access non-local resources, then no, it probably isn't a double-hop problem. But it sounds as if you may be asking the session to access non-local resources, since running the script when logged in on the console works.