}
}
else {
- :excludeOuter foreach($rDb in $databases) {
+ :excludeOuter
+ foreach($rDb in $databases) {
if($rDb -in $configDbExclude) {
continue;
}
$databaseBackupDir = Join-Path -Path $configBackupDir -ChildPath $d
if(!(Test-Path $databaseBackupDir)) {
- New-Item -ItemType directory -Path $databaseBackupDir -ErrorAction Stop | Out-Null
+ try {
+ New-Item -ItemType directory -Path "$databaseBackupDir" -ErrorAction Stop | Out-Null
+ }
+ catch {
+ Write-Output "Failed to create directory $databaseBackupDir"
+ Write-Output $_
+ exit 1
+ }
}
$databaseBackupFile = Join-Path -Path $databaseBackupDir -ChildPath "backup-$d-$currDaytime.sql"