This project is read-only.


Aug 25, 2010 at 12:37 AM

Is there a way to use multiple backup files with invoke-sqlbackup?  I keep getting failures for one of my large databases when backing up to a single file.

Aug 25, 2010 at 2:37 AM

The Invoke-SqlBackup and Invoke-SqlRestore functions are not written to handle multiple files however you could easily modify the function in sqlserver.psm1 to do so:

Note I haven't tested...

Change this

[Parameter(Position=2, Mandatory=$true)] [string]$filepath,

to this:

[Parameter(Position=2, Mandatory=$true)] $filepath,

Then change this

$backupDevice = new-object ("Microsoft.SqlServer.Management.Smo.BackupDeviceItem") $filepath, 'File'

To this:

$filepath | foreach {$backupDevices += new-object ("Microsoft.SqlServer.Management.Smo.BackupDeviceItem") $_, 'File' }

And change this line:


To this

$backupDevices | foreach { $backup.Devices.Add($_) }

And then to call the modified function you'll need to specify an array of files:

invoke-sqlbackup <....> -filepath @('c:\file1.bak','C:\file2.bak')