]> git.p6c8.net - psmysqlbackup.git/blobdiff - psmysqlbackup.ps1
Catch exception when creating a directory for a database backup
[psmysqlbackup.git] / psmysqlbackup.ps1
index 03d63ea12cdc611ba77431a07f1b3d220da285ea..f544cca7efeb2a738ea8692da91147a7edeb04b5 100644 (file)
@@ -111,7 +111,14 @@ foreach($d in $databasesToBackup) {
     $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"

patrick-canterino.de