+try {
+ $databases = Get-Databases | Where-Object {!($_ -in $defaultDbExclude)}
+}
+catch {
+ Write-Output "Failed to get list of databases"
+ Write-Output $_
+ exit 1
+}
+
+$databasesToBackup = @()
+
+if($configDbBackup -and $configDbBackup.count -gt 0) {
+ foreach($cDb in $configDbBackup) {
+ if($cDb -in $databases) {
+ $databasesToBackup += $cDb
+ }
+ else {
+ Write-Warning "Not backing up database $cDb, because it does not exist"
+ }
+ }
+}
+else {
+ :excludeOuter foreach($rDb in $databases) {
+ if($rDb -in $configDbExclude) {
+ continue;
+ }