& $configMysqldumpCli --host=$configMysqlHost --user=$configMysqlUser --password=$configMysqlPassword --single-transaction --result-file=$target $database
}
+$currDaytime = Get-Date -format "yyyyMMdd-HHmmss"
+
$databases = Get-Databases | Where-Object { $_ -ne "information_schema" -and $_ -ne "performance_schema"}
foreach($d in $databases) {
- $backupFile = $configBackupDir + "\" + $d + ".sql"
- Write-Output "Backing up $d to $backupFile..."
- Create-Backup $d $backupFile
+ $databaseBackupDir = Join-Path -Path $configBackupDir -ChildPath $d
+
+ if(!(Test-Path $databaseBackupDir)) {
+ New-Item -ItemType directory -Path $databaseBackupDir -ErrorAction Stop | Out-Null
+ }
+
+ $databaseBackupFile = Join-Path -Path $databaseBackupDir -ChildPath "backup-$d-$currDaytime.sql"
+ Write-Output "Backing up $d to $databaseBackupFile..."
+ Create-Backup $d $databaseBackupFile
}
\ No newline at end of file