Skip to content

Instantly share code, notes, and snippets.

@chuckboycejr
chuckboycejr / SimplePowershellBackupSystem.ps1
Created January 6, 2020 06:10
Backup all user and system databases except for TEMPDB. Compress all SQL backups to local disk using 7zip. Copy backups to multiple locations based on configurations. Get MD5 hash for multiple locations and roll back the copy if the hashes don't match.
Import-Module -Name SqlServer
# CONFIGURATIONS:
$locationA = "C:\temp\share1"
$locationB = "C:\temp\\share2"
$local = "C:\temp"
$SqlServerLocation = "SQLSERVER:\SQL\localhost\DEFAULT\Databases"
$retries = 5