- $backupFile = $config_backup_dir + "\" + $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