# Remote Sql Server backups 

**URL:** <https://forums.powershell.org/t/remote-sql-server-backups/2430>\
**Category:** PowerShell Help\
**Created:** [April 8, 2014, 8:37pm UTC](https://forums.powershell.org/t/remote-sql-server-backups/2430 "2014-04-08T20:37:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregor-suttie](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/gregor-suttie/32/897_2.png) [@gregor-suttie](https://forums.powershell.org/u/gregor-suttie)\
**Post date:** [April 8, 2014, 8:37pm UTC](https://forums.powershell.org/t/remote-sql-server-backups/2430/1 "2014-04-08T20:37:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [April 9, 2014, 9:20pm UTC](https://forums.powershell.org/t/remote-sql-server-backups/2430/2 "2014-04-09T21:20:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/remote-sql-server-backups/2430/3 "2024-05-16T20:52:14Z")

</div>


