]> git.p6c8.net - psmysqlbackup.git/commitdiff
Catch exception when creating a directory for a database backup 0.1
authorPatrick Canterino <patrick@patrick-canterino.de>
Sat, 1 Jan 2022 16:41:46 +0000 (17:41 +0100)
committerPatrick Canterino <patrick@patrick-canterino.de>
Sat, 1 Jan 2022 16:41:46 +0000 (17:41 +0100)
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