4

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?

Scott Weinstein
  • 315
  • 3
  • 10
  • 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 03 '09 at 19:33

3 Answers3

1

Here's a link to a script I created

Chad Miller
  • 1,091
  • 8
  • 11
1

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.

Ivo Looser
  • 311
  • 1
  • 4
0

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

Marko Carter
  • 4,092
  • 1
  • 29
  • 38