]> git.p6c8.net - psmysqlbackup.git/commitdiff
Fixed backup exclusions and allow only to backup a selection of databases
authorPatrick Canterino <patrick@patrick-canterino.de>
Tue, 28 Dec 2021 12:32:38 +0000 (13:32 +0100)
committerPatrick Canterino <patrick@patrick-canterino.de>
Tue, 28 Dec 2021 12:32:38 +0000 (13:32 +0100)
psmysqlbackup.ps1

index 04ca03aaf77bf9094c19dc7b5b508f2db89a85fa..97bcf859f3791b3bd8e3481a6a17b1a1e81fa886 100644 (file)
@@ -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)) {

patrick-canterino.de