From: Patrick Canterino Date: Wed, 29 Dec 2021 12:32:42 +0000 (+0100) Subject: Before backing up a selection of database, check if the databases exist X-Git-Tag: 0.1~7 X-Git-Url: https://git.p6c8.net/psmysqlbackup.git/commitdiff_plain/a463cecd9b193a49f93ac06c44ee3cdfa3d38128?ds=sidebyside;hp=1709a66946731ebe8f373f398af5749c90fb4b64 Before backing up a selection of database, check if the databases exist --- diff --git a/psmysqlbackup.ps1 b/psmysqlbackup.ps1 index d11f52e..1e23c5e 100644 --- a/psmysqlbackup.ps1 +++ b/psmysqlbackup.ps1 @@ -80,7 +80,14 @@ catch { $databasesToBackup = @() if($configDbBackup -and $configDbBackup.count -gt 0) { - $databasesToBackup = $configDbBackup + foreach($cDb in $configDbBackup) { + if($cDb -in $databases) { + $databasesToBackup += $cDb + } + else { + Write-Warning "Not backing up database $cDb, because it does not exist" + } + } } else { $databasesToBackup = $databases