Advertisement
mike_fal

Backup-SQLDatabase example

May 28th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $SQLServer = 'SHION\ALBEDO'
  2. $StatementTimeout = 0
  3.  
  4. $DatabaseName = 'restoredemo_migration'
  5. $DatabaseBackup = "C:\temp\$DatabaseName.bak"
  6.  
  7. ### Backup database. Changed to using SQL Connection object so I can control the timeout.
  8. $SQLServerConn = new-object ("Microsoft.SqlServer.Management.Smo.Server") $SQLServer
  9. $SQLServerConn.ConnectionContext.StatementTimeout = $StatementTimeout
  10.  
  11. Backup-SqlDatabase -InputObject $SQLServerConn -Database $DatabaseName -BackupFile $DatabaseBackup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement