Skip to content

January 30, 2013


Extract a RedGate SPB Backup with Powershell

by Scott Newman

Quick post on how to extract a red gate sqlbackup file back to native format using powershell.  There’s no redgate cmdlets to do this, I’m just using invoke-expression (or use the ampersand for shorthand) to extract the backups.  This will create multiple .bak files; one per each thread according to the number of threads that were specified when creating the original backup.

$file = "C:\PathToOriginalSPB_Backup\OriginalBackup.sqb"
$extractor = "C:\Program Files (x86)\Red Gate\SQL Backup 7\sqb2mtf.exe"
$destination = "C:\WhereYouWantYourExtractedBackupsToGO\NativeBackups.bak"

$params = "`"$($file)`"", "`"$($destination)`""

& $extractor $params
Read more from Powershell, SQL Server
3 Comments Post a comment
  1. mark
    Jan 31 2013

    I hade figured this out as well , now I all I need to figure out is how do a restore in powershell from multiple bak files….smo.BackupDeviceItem
    does not seem to accept an array or have an ,add method 😦

  2. mark
    Jan 31 2013


    $connection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection(“tdb01-sqltest”)
    $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($connection)
    $rstDatabase = New-Object Microsoft.SqlServer.Management.Smo.Restore
    $rstDatabase.Action = [Microsoft.SqlServer.Management.Smo.RestoreActionType]::Database
    $rstDatabase.Database = “ApproveIT-Main”
    $rstDatabase.ReplaceDatabase = “true”
    foreach ( $file in $files) {
    $bkpDevice = New-Object Microsoft.SqlServer.Management.Smo.BackupDeviceItem($file.Fullname, [Microsoft.SqlServer.Management.Smo.DeviceType]::File)

    $rstDatabase.ReplaceDatabase = $true

    seems to work.

    PS H:\> $rstDatabase.Devices | select name


  3. Jan 31 2013

    Yup, was going to post that myself. I’ve got the restore part working also. Well, until I found a TDE enabled database that is….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: