Last active
September 16, 2022 08:39
-
-
Save tdewin/ac3fe1d7865346074be4bb8740b19dfd to your computer and use it in GitHub Desktop.
Backup of Veeam Backup & Replication Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $bpath = "c:\temp\" | |
| New-Item -Type Directory $bpath -ErrorAction ignore | |
| $datestr = ("{0}" -f (Get-Date -Format "yyyyMMdd-hhmmss")) | |
| $bdatepath = join-path -Path $bpath -ChildPath ("veeambackup-{0}" -f $datestr) | |
| New-Item -Type Directory $bdatepath | |
| $props = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Veeam\Veeam Backup and Replication\' | |
| $fpath = join-path -Path $bdatepath -childpath ("sqldump-{0}-{1}.bak" -f $props.SqlDatabaseName,$datestr) | |
| Backup-SqlDatabase -ServerInstance ("{0}\{1}" -f $props.SqlServerName,$props.SqlInstanceName) -Database $props.SqlDatabaseName -BackupFile $fpath | |
| $todate = (Get-Date) | |
| $fromdate = $todate.AddDays(-7) | |
| $allservers = Get-VBRServer | |
| Export-VBRLogs -Server $allservers -FolderPath $bdatepath -Compress -From $fromdate -To $todate | |
| Compress-Archive -LiteralPath $bdatepath -DestinationPath ("{0}.zip" -f $bdatepath) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I feel lucky