0

I could successfully backup database using Backup-Sqldatabase cmdlet to one .bak file. However, I was want to generate stripped backup files for the database. Is this possible using the cmdlet?

1
  • Are you sure striped backups are what you really need? Commented May 24, 2016 at 20:26

2 Answers 2

1

The cmdlet has a parameter -backupFile that accetps an array of file names. At least with the -Script parameter the emitted TSQL looks sensible, so it ought to work. Like so,

PS SQLSERVER:\> Backup-SqlDatabase -Script -ServerInstance ".\sqli001" -Database TestDB -BackupFile @("c:\temp\1.bak", "c:\temp\2.bak")

BACKUP DATABASE [TestDB] TO  DISK = N'c:\temp\1.bak',  DISK = N'c:\temp\2.bak' WITH NOFORMAT, NOINIT, NOSKIP, REWIND, NOUNLOAD,  STATS = 10
GO
Sign up to request clarification or add additional context in comments.

Comments

0

This will only generate the code to take backup.

Use the below PowerShell script to execute the backup and I have provided a way to pass the dynamic value to the backup file path as well shown below.

 $path = 'D:\BackupFolder\TestDB.Bak,E:\BackupFolder\TestDB.Bak'

 $QUERY = Backup-SqlDatabase -Script -ServerInstance ServerName  -Database TestDB -BackupFile @($path.split(','))

 invoke-sqlcmd -query "$QUERY" -ServerInstance "SQLInstanceName"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.