Skip to content

Commit 52bf698

Browse files
author
Uwe Janke
committed
v1.8.12.0: New-sqmOlaUsrDbBackupJob - explicit -BackupDirectory no longer gets \Usr-db appended
An explicitly passed -BackupDirectory was always suffixed with \Usr-db, even when the caller supplied the full intended target path. Now \Usr-db is only appended to auto-detected paths (registry / SMO BackupDirectory / default); an explicit -BackupDirectory is used verbatim. Verified on DEV02: -BackupDirectory "C:\Temp\ExplicitTestPath" resolves to that exact path with no suffix.
1 parent 33f560c commit 52bf698

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

CHANGELOG.md

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

3+
## [1.8.12.0] — 2026-07-02
4+
5+
### Bugfix
6+
7+
**`New-sqmOlaUsrDbBackupJob`** — expliziter `-BackupDirectory` wurde ueberschrieben
8+
- Bisher wurde an JEDEN ermittelten Backup-Pfad `\Usr-db` angehaengt, auch wenn
9+
der Aufrufer `-BackupDirectory` explizit als vollstaendigen Zielpfad uebergeben
10+
hat. Fix: `\Usr-db` wird nur noch an automatisch ermittelte Pfade (Registry /
11+
`sqlSrv.BackupDirectory` / Default) angehaengt; ein explizit gesetzter
12+
`-BackupDirectory` wird unveraendert als Zielpfad verwendet.
13+
- Verifiziert auf DEV02: `-BackupDirectory "C:\Temp\ExplicitTestPath"` ergibt
14+
exakt diesen Pfad ohne Suffix.
15+
316
## [1.8.11.0] — 2026-07-02
417

518
### Bugfix

Public/New-sqmOlaUsrDbBackupJob.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
PSCredential for the SQL connection.
2828
2929
.PARAMETER BackupDirectory
30-
Backup base directory. User databases are backed up to <BackupDirectory>\Usr-db.
31-
Default: automatically determined from SQL Server.
30+
Backup target directory. When omitted, the base directory is automatically determined
31+
from SQL Server and '\Usr-db' is appended. When explicitly specified, the given path is
32+
used as-is (no '\Usr-db' is appended) — pass the full, final backup path.
3233
3334
.PARAMETER Databases
3435
Database filter for Ola. E.g. 'USER_DATABASES', 'ALL_DATABASES', or
@@ -430,7 +431,17 @@ function New-sqmOlaUsrDbBackupJob
430431
if (-not $effBackupDir) { $effBackupDir = $sqlSrv.BackupDirectory }
431432
}
432433
if (-not $effBackupDir) { $effBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL\Backup' }
433-
$usrBackupDir = "$effBackupDir\Usr-db"
434+
435+
# Explizit uebergebener -BackupDirectory wird unveraendert als Zielpfad verwendet;
436+
# nur bei automatisch ermitteltem Pfad wird '\Usr-db' angehaengt.
437+
if ($PSBoundParameters.ContainsKey('BackupDirectory') -and $BackupDirectory)
438+
{
439+
$usrBackupDir = $BackupDirectory
440+
}
441+
else
442+
{
443+
$usrBackupDir = "$effBackupDir\Usr-db"
444+
}
434445
Invoke-sqmLogging -Message "Backup-Verzeichnis fuer User-Datenbanken: $usrBackupDir" -FunctionName $functionName -Level "INFO"
435446

436447
# 3. SA-Login und Job-Kategorie

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.11.0'
20+
ModuleVersion = '1.8.12.0'
2121

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

0 commit comments

Comments
 (0)