From: Patrick Canterino Date: Tue, 28 Dec 2021 12:32:38 +0000 (+0100) Subject: Fixed backup exclusions and allow only to backup a selection of databases X-Git-Tag: 0.1~15 X-Git-Url: https://git.p6c8.net/psmysqlbackup.git/commitdiff_plain/c8443b63a6a7a513388cad85ff1651bfb0281b09?hp=be998b79b9e8fe795075936b8e6819ead2f2b52a Fixed backup exclusions and allow only to backup a selection of databases --- diff --git a/psmysqlbackup.ps1 b/psmysqlbackup.ps1 index 04ca03a..97bcf85 100644 --- a/psmysqlbackup.ps1 +++ b/psmysqlbackup.ps1 @@ -9,7 +9,8 @@ [String]$configBackupDir = "backup" [Int32]$configRotate = 7 -[String]$configDbExclusions = @("test") +$configDbBackup = @() +$configDbExclusions = @("test") $defaultExclusions = @("information_schema", "performance_schema") @@ -48,7 +49,16 @@ $currDaytime = Get-Date -format "yyyyMMdd-HHmmss" $databases = Get-Databases | Where-Object {!($_ -in $defaultExclusions -or $_ -in $configDbExclusions)} -foreach($d in $databases) { +$databasesToBackup = @() + +if($configDbBackup -and $configDbBackup.count -gt 0) { + $databasesToBackup = $configDbBackup +} +else { + $databasesToBackup = $databases +} + +foreach($d in $databasesToBackup) { $databaseBackupDir = Join-Path -Path $configBackupDir -ChildPath $d if(!(Test-Path $databaseBackupDir)) {