Skip to content

Commit 8a4475f

Browse files
author
Uwe Janke
committed
v1.8.13.0: CRITICAL FIX - New-sqmOlaUsrDbBackupJob exclude filter polarity was inverted
IsActive=1 in sqm_BackupExclude means "back this database up" (default for newly discovered databases via Sync-sqmBackupExcludeTable), IsActive=0 means "do not back up". The exclude query added in v1.8.11.0 filtered on IsActive=1, which excluded exactly the databases that should have been backed up and backed up the ones explicitly marked as excluded - fully inverted. Fixed filter to WHERE e.IsActive = 0. Verified on DEV02: real FULL run now backs up all IsActive=1 databases and correctly skips the IsActive=0 ones.
1 parent 52bf698 commit 8a4475f

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# sqmSQLTool — Changelog
22

3+
## [1.8.13.0] — 2026-07-02
4+
5+
### Bugfix (kritisch)
6+
7+
**`New-sqmOlaUsrDbBackupJob`** — IsActive-Polaritaet in der Exclude-Abfrage invertiert
8+
- Die in v1.8.11.0 gefixte Abfrage filterte auf `e.IsActive = 1`, um Ausschluesse zu
9+
bilden. Tatsaechliche Bedeutung von `IsActive` in `sqm_BackupExclude`: `IsActive=1`
10+
heisst "diese Datenbank soll gesichert werden" (Default fuer neu entdeckte
11+
Datenbanken, siehe `Sync-sqmBackupExcludeTable`), `IsActive=0` heisst "nicht sichern".
12+
Mit `WHERE IsActive = 1` wurden also genau die zu sichernden Datenbanken
13+
ausgeschlossen und die explizit stillgelegten (`IsActive=0`) gesichert — Polaritaet
14+
komplett invertiert.
15+
- Fix: Filter auf `e.IsActive = 0` korrigiert.
16+
- Verifiziert auf DEV02: echter FULL-Lauf sichert jetzt exakt die 9 Datenbanken mit
17+
`IsActive=1` (`AlwaysOnTest, amazon, DeadlockCollector, dtcSN, OperationsManagerDW,
18+
pdRessourcen, ReportServerTempDB, Solutioninfo, SolutioninfoSTA`) und uebersprang
19+
korrekt die 3 mit `IsActive=0` (`SSISDB, TestDB, ReportServer`).
20+
- `Sync-sqmBackupExcludeTable` (Default `IsActive=1` fuer neue Datenbanken) war von
21+
Anfang an korrekt und musste NICHT geaendert werden — der Fehler lag ausschliesslich
22+
in der Leserichtung dieser einen Abfrage.
23+
324
## [1.8.12.0] — 2026-07-02
425

526
### Bugfix

Public/New-sqmOlaUsrDbBackupJob.ps1

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
OlaJobNameLog (Default: 'OlaHH-UserDatabases-LOG')
1515
1616
When -UseExcludeTable is set, the function reads master.dbo.sqm_BackupExclude
17-
(created by Sync-sqmBackupExcludeTable) for entries where IsActive=1 AND IsOrphaned=0
18-
AND the database actually exists on this instance (sys.databases). If entries are found,
19-
they are prepended with '-' (Ola's exclude prefix) and appended to the @Databases parameter
20-
in the generated job step command. If the table does not exist or contains no matching rows,
21-
the -Databases parameter is used unchanged.
17+
(created by Sync-sqmBackupExcludeTable) for entries where IsActive=0 (database should
18+
NOT be backed up) AND IsOrphaned=0 AND the database actually exists on this instance
19+
(sys.databases). If entries are found, they are prepended with '-' (Ola's exclude prefix)
20+
and appended to the @Databases parameter in the generated job step command. If the table
21+
does not exist or contains no matching rows, the -Databases parameter is used unchanged.
22+
Note: IsActive=1 means "back this database up" (the default for newly discovered
23+
databases); IsActive=0 means "exclude this database".
2224
2325
.PARAMETER SqlInstance
2426
SQL Server instance. Default: current computer name.
@@ -111,10 +113,11 @@
111113
Continue with remaining jobs if one job fails.
112114
113115
.PARAMETER UseExcludeTable
114-
When set, reads master.dbo.sqm_BackupExclude for active, non-orphaned entries that exist
115-
on this instance and adds them as '-DatabaseName' exclusions to the @Databases parameter
116-
of Ola's DatabaseBackup. If the table does not exist or is empty, the Databases parameter
117-
is used unchanged.
116+
When set, reads master.dbo.sqm_BackupExclude for non-orphaned entries with IsActive=0
117+
(databases explicitly marked as "do not back up") that exist on this instance, and adds
118+
them as '-DatabaseName' exclusions to the @Databases parameter of Ola's DatabaseBackup.
119+
IsActive=1 (the default for newly discovered databases) means "back this database up".
120+
If the table does not exist or no rows match, the Databases parameter is used unchanged.
118121
119122
.PARAMETER CreateSyncJob
120123
When -UseExcludeTable is set, automatically creates a SQL Agent job that runs
@@ -571,7 +574,7 @@ BEGIN
571574
SELECT @Exclusions = STUFF((
572575
SELECT ',-' + e.DatabaseName
573576
FROM master.dbo.sqm_BackupExclude e
574-
WHERE e.IsActive = 1
577+
WHERE e.IsActive = 0
575578
AND e.IsOrphaned = 0
576579
AND EXISTS (SELECT 1 FROM sys.databases d WHERE d.name = e.DatabaseName)
577580
FOR XML PATH(''), TYPE

sqmSQLTool.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
RootModule = 'sqmSQLTool.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '1.8.12.0'
20+
ModuleVersion = '1.8.13.0'
2121

2222
# ID used to uniquely identify this module
2323
GUID = 'c4b10ba2-aee2-4d8d-ad86-a6e97c346ba6'

0 commit comments

Comments
 (0)