From c8443b63a6a7a513388cad85ff1651bfb0281b09 Mon Sep 17 00:00:00 2001 From: Patrick Canterino Date: Tue, 28 Dec 2021 13:32:38 +0100 Subject: [PATCH] Fixed backup exclusions and allow only to backup a selection of databases --- psmysqlbackup.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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)) { -- 2.34.1