I'm looking for a script to restore a SQL Server 2005 backup. Ideally the script will have the following features

  • handle backup files on a network location
  • Handle different file structure of source and destination server ("With MOVE"?)
  • Written in PowerShell

Any suggestions?

link|improve this question

50% accept rate
I'm curious why you want to use PowerShell to run a SQL Command, when the Native T/SQL command will probably be easier to find and use? – mrdenny Aug 3 '09 at 19:33
feedback

3 Answers

Here's a link to a script I created

link|improve this answer
feedback

I'm using link text. Ok, is not really a Powershell script. But it works on all Servers, 2000 or 2005 so far. And it does a great job for me. Just executing master..usp_build_restore_script and copy the relevant part for the Restore.

I did also an extension in Powershell. As a sample, before i execute a Restore, i like to see if the necessary files really exists or not. For this i just execute the master..usp_build_restore_script from Powershell and use test-path on all Backupfiles.

link|improve this answer
feedback

Not sure about the different structures but this post at sqlmusings.com should be agood starting point for you.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.