GrayMP

Backup database

Apr 5th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. $Source = "c:\temp\posilator_prod.bak"
  2. $Target = "c:\temp\posilator_prod.zip"
  3.  
  4. if([System.IO.File]::Exists($Target)){
  5. Remove-item $Target
  6. }
  7.  
  8. if([System.IO.File]::Exists($Source)){
  9. Remove-item $Source
  10. }
  11.  
  12. Backup-SqlDatabase -ServerInstance . -Database posilator_prod -BackupAction Database -BackupFile 'c:\temp\posilator_prod.bak'
  13.  
  14.  
  15. if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"}
  16. set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
  17.  
  18.  
  19. sz a -mx=4 $Target $Source
  20.  
  21. if([System.IO.File]::Exists($Source)){
  22. Remove-item $Source
  23. }
Add Comment
Please, Sign In to add comment