· Uwe Janke
Commands / Test-sqmTdpBackup

Test-sqmTdpBackup

Backup sqmSQLTool v1.9.217+ · Test ✓ -WhatIf supported
Checks the TDP (IBM Spectrum Protect for SQL) backup solution end to end and names a fix for every problem it finds. It does not trust a single source, because some failures leave no trace in the usual places: the Agent job reports success although nothing was backed up.

Backup age comes from msdb (virtual device backups, device_type = 7) and is therefore independent of the tracking tables the TDP script writes itself. The limits are derived from the schedule in BackupPlan.json (longest gap between two full days, or between two backup days, plus -MarginHours); without a readable plan the defaults are 8 days and 26 hours.

Without SQL access the function does not abort: it falls back to the file-only check of Test-sqmTdpConfiguration on the instance's host and adds a Critical finding "SQL Server not reachable". SqlReachable in the result is then $false. -NoFileFallback throws the connection error instead.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestring[]Optional$env:COMPUTERNAMESQL Server instance(s). Pipeline-capable.
-SqlCredentialPSCredentialOptional, SQL authentication.
-TdpDirstringOptionalC:\Program Files\Tivoli\TSM\TDPSqlTDP directory on the instance's host.
-JobNamestringOptionalTDP_Backup_DailyName of the SQL Agent job.
-ConfigPathstringOptional<TdpDir>\BackupPlan.jsonPath of BackupPlan.json.
-MaxFullAgeDaysintOptional0 (derive)Maximum age of the newest TDP full. 0 = from the schedule, fallback 8 days.
-MaxAnyAgeHoursintOptional0 (derive)Maximum age of the newest TDP full or diff. 0 = from the schedule, fallback 26 hours.
-MarginHoursintOptional12Tolerance added to the derived limits (the backup finishes hours after the job start).
-HistoryDaysintOptional35Job history and msdb window.
-LogFilesToScanintOptional5Number of newest logs scanned.
-TestTsmServerswitchSwitch$falseTCP test of the TSM server from dsm.opt (local computer only).
-ExcludeDatabasestring[]Optional, Databases not to check. Wildcards allowed.
-NoFileFallbackswitchSwitch$falseThrow when SQL is not reachable instead of falling back to the file-only check.
-OutputPathstringOptional<OutputPath config>\TdpBackupReport directory.
-NoOpenswitchSwitch$falseDo not open the HTML report.
-NoReportswitchSwitch$falseWrite no files, only return the result object.
-ContinueOnErrorswitchSwitch$falseContinue with the next instance or computer on error.
-EnableExceptionswitchSwitch$falseThrow exceptions immediately.

Execution Flow

START SQL Server reachable? NO Fallback file check only SQL finding Critical YES Files, BackupPlan.json, wrapper, logs same checks as Test-sqmTdpConfiguration, read locally or via \\host\C$ limits for the backup age are derived from the schedule in BackupPlan.json SQL Server Agent service running, job enabled, enabled schedule, CmdExec step, proxy enabled last run ok and not overdue, run hanging, failed runs in the history Tracking in master TDP_BackupPlan, BackupStatus, BackupLog and the procedures exist BackupLog written by every job run (job ok but log stale = script did nothing) Plan against databases plan database without BackupStatus row is never backed up (INNER JOIN) vanished databases, user databases outside the plan, JSON against table Backups per database (msdb, device_type 7) age of the newest TDP full and diff against the limits, consecutive failures SUCCESS logged without a backup in msdb, non-TDP full newer than the TDP full differential without full, FULL recovery without log backup Findings by severity, report TXT, CSV and HTML; result object with Findings and DatabaseRows END

What it checks

AreaChecks
AgentAgent service, job exists and is enabled, enabled schedule, CmdExec step, proxy enabled, last run ok, run overdue (daily schedule), run hanging over 12 h, failed runs of the last 7 days
Trackingmaster tables and procedures exist; BackupLog written by every job run
PlanTDP_BackupPlan filled; every plan database has a BackupStatus row; plan databases that no longer exist; user databases outside the plan; BackupPlan.json against the table
BackupsAge of the newest TDP full and diff from msdb; consecutive failures with the last error; SUCCESS logged without a backup in msdb; non-TDP full newer than the TDP full; differential without full; FULL recovery without log backup
FilesSee Test-sqmTdpConfiguration: BackupPlan.json, tdpsqlc.exe, dsm.opt, tdpsql.cfg, TdpBackup.config, wrapper
LogsWrapper logs (FAILED, unfinished), per-database TDP logs and tdpsql.log: ANS/ACN/ACO messages, E = Warning, S = Critical

Return value

One object per instance with Status (OK, Warning, Critical, Error), SqlReachable, the counts, MaxFullAgeHours, MaxAnyAgeHours, LimitSource, Findings (Severity, Category, Database, Message, Hint), DatabaseRows and the report file paths.

SeverityMeaning
CriticalThe backup is not working or the data is not protected. Changes the overall status to Critical.
WarningNeeds attention but the backup still runs. Overall status Warning.
InfoGood to know (for example a step runs without a proxy). Does not change the overall status.

TDP backups are recognised by device_type 7. Another VDI-based backup product on the same instance would be counted as TDP.

Examples

Check one instance, report opens in the browser
Test-sqmTdpBackup -SqlInstance "SQL01"
Only what needs attention, no files
(Test-sqmTdpBackup -SqlInstance "SQL01" -NoReport).Findings |
    Where-Object Severity -ne 'Info' | Format-List Severity, Category, Database, Message, Hint
Non-default TDP directory and TSM server test
Test-sqmTdpBackup -SqlInstance "SQL01" -TdpDir 'D:\Tivoli\TDPSql' -TestTsmServer
Fixed limits instead of the schedule
Test-sqmTdpBackup -SqlInstance "SQL01" -MaxFullAgeDays 8 -MaxAnyAgeHours 30
Throw instead of falling back when SQL is down
Test-sqmTdpBackup -SqlInstance "SQL01" -NoFileFallback