X-Git-Url: https://git.p6c8.net/psmysqlbackup.git/blobdiff_plain/be998b79b9e8fe795075936b8e6819ead2f2b52a..1ac4e9b9a84a03bf415695f0420c12c3fa536ed2:/psmysqlbackup.ps1 diff --git a/psmysqlbackup.ps1 b/psmysqlbackup.ps1 index 04ca03a..cc422a6 100644 --- a/psmysqlbackup.ps1 +++ b/psmysqlbackup.ps1 @@ -1,15 +1,20 @@ -[String]$configMysqlHost = "localhost" -[Int32]$configMysqlPort = 3306 -[String]$configMysqlUser = "backup" -[String]$configMysqlPassword = "backup" +# Config -[String]$configMysqlCli = "C:\Program Files\MariaDB 10.5\bin\mysql.exe" -[String]$configMysqldumpCli = "C:\Program Files\MariaDB 10.5\bin\mysqldump.exe" +$configMysqlHost = "localhost" +$configMysqlPort = 3306 +$configMysqlUser = "backup" +$configMysqlPassword = "backup" -[String]$configBackupDir = "backup" -[Int32]$configRotate = 7 +$configMysqlCli = "C:\Program Files\MariaDB 10.5\bin\mysql.exe" +$configMysqldumpCli = "C:\Program Files\MariaDB 10.5\bin\mysqldump.exe" -[String]$configDbExclusions = @("test") +$configBackupDir = "backup" +$configRotate = 7 + +$configDbBackup = @() +$configDbExclusions = @("test") + +# End of config $defaultExclusions = @("information_schema", "performance_schema") @@ -48,7 +53,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)) {