Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 Powershell script to move backups

Author  Topic 

tstrub
Starting Member

4 Posts

Posted - 2013-10-30 : 15:47:34
Hello

I am attempting to set up a job where nightly backups are moved off the local server onto a different server; the job fails however at the second step where I have a powershell script run. The script is:

powershell.exe -NoLogo -NoProfile -Command "&'C:\scripts\sql\copy_to_fileserver.ps1' 'companydb.bak'"

I am not sure whether the script is in error or if there is something set wrong in the permissions to allow the move. Any ideas where I should be looking?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-10-30 : 15:57:55
Is it giving you any error message at all?

If this is the first time you are running a powershell script, you would need to set the execution policy. By default it is Restricted, which will prevent scripts in files from being run. http://technet.microsoft.com/en-us/library/hh849812.aspx

If that is not the case, see if you are able to run the script (C:\scripts\sql\copy_to_fileserver.ps1) from a powershell interactive window - which will tell you if the script is in error.
Go to Top of Page

tstrub
Starting Member

4 Posts

Posted - 2013-10-30 : 17:25:56
We run AllSigned execution policy on this machine. Running in powershell, both the scripts run, but nothing happens -no files are transferred and no error messages. Since this script is running as a SQLAgent job, would there be an issue with permissions on the destination directory?
Go to Top of Page
   

- Advertisement -