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 <servername>
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