Also, the databases matching the exclusions defined in $configDbExclude are now
removed later in the script. This means that when backing up a selection of
databases, $configDbExclude does not apply.
- [x] Allow to define exclusions
- [x] Backup a selection of databases
- [x] Rotate backups after `n` backups
- [x] Allow to define exclusions
- [x] Backup a selection of databases
- [x] Rotate backups after `n` backups
-- [ ] Allow to define exclusions based on regular expressions
+- [x] Allow to define exclusions based on regular expressions
- [ ] Error handling
- [ ] Configuration file
- [ ] Write log file
- [ ] Error handling
- [ ] Configuration file
- [ ] Write log file
$configDbBackup = @()
$configDbExclude = @("test")
$configDbBackup = @()
$configDbExclude = @("test")
+$configDbExcludePattern = @()
$currDaytime = Get-Date -format "yyyyMMdd-HHmmss"
try {
$currDaytime = Get-Date -format "yyyyMMdd-HHmmss"
try {
- $databases = Get-Databases | Where-Object {!($_ -in $defaultDbExclude -or $_ -in $configDbExclude)}
+ $databases = Get-Databases | Where-Object {!($_ -in $defaultDbExclude)}
}
catch {
Write-Output "Failed to get list of databases"
}
catch {
Write-Output "Failed to get list of databases"
- $databasesToBackup = $databases
+ :excludeOuter foreach($rDb in $databases) {
+ if($rDb -in $configDbExclude) {
+ continue;
+ }
+
+ foreach($cPattern in $configDbExcludePattern) {
+ if($rDb -match $cPattern) {
+ continue excludeOuter;
+ }
+ }
+
+ $databasesToBackup += $rDb
+ }
}
foreach($d in $databasesToBackup) {
}
foreach($d in $databasesToBackup) {