You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sp_BlitzBackups: use @starttime for NUL device check
Honor the @HoursBack parameter instead of a hard-coded 30-day window,
matching the convention used elsewhere in this proc, and drop the
"in the last 30 days" wording from the warning text now that the window
is dynamic.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: sp_BlitzBackups.sql
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1109,33 +1109,33 @@ IF @ProductVersionMajor >= 12
1109
1109
100 AS [Priority],
1110
1110
bs.database_name AS [Database Name],
1111
1111
''Backup to NUL device'' AS [Finding],
1112
-
''The database '' + QUOTENAME(bs.database_name) + '' has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' backups to the NUL device in the last 30 days, the latest one being on ''+
1112
+
''The database '' + QUOTENAME(bs.database_name) + '' has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' backups to the NUL device, the latest one being on ''+
1113
1113
CONVERT(NVARCHAR(25),MAX(bs.backup_finish_date),120)+''. These backups do not exist.'' AS [Warning]
1114
1114
FROM '+QUOTENAME(@MSDBName) +'.dbo.backupset AS bs
1115
1115
INNER JOIN '+QUOTENAME(@MSDBName) +'.dbo.backupmediafamily bmf ON bs.media_set_id = bmf.media_set_id
1116
1116
WHERE UPPER(bmf.physical_device_name)= N''NUL''
1117
1117
AND (bs.is_copy_only = 1 OR bs.recovery_model = N''SIMPLE'')
1118
-
AND bs.backup_finish_date >= DATEADD(DAY, -30, SYSDATETIME())
1118
+
AND bs.backup_finish_date >= @StartTime
1119
1119
GROUP BY bs.database_name'+ @crlf;
1120
-
SET @StringToExecute +=N'UNION ALL'+ @crlf + N'SELECT
1120
+
SET @StringToExecute +=N'UNION ALL'+ @crlf + N'SELECT
1121
1121
14 AS CheckId,
1122
1122
100 AS [Priority],
1123
1123
bs.database_name AS [Database Name],
1124
1124
''Backup to NUL device without COPY_ONLY'' AS [Finding],
1125
-
''The database '' + QUOTENAME(bs.database_name) + '' is not in SIMPLE recovery model and has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' backups to the NUL device in the last 30 days, the latest one being on ''+
1125
+
''The database '' + QUOTENAME(bs.database_name) + '' is not in SIMPLE recovery model and has had '' + CONVERT(VARCHAR(10), COUNT(*)) + '' backups to the NUL device, the latest one being on ''+
1126
1126
CONVERT(NVARCHAR(25),MAX(bs.backup_finish_date),120)+''. These backups do not exist and they might mess up your current backup chain.'' AS [Warning]
1127
1127
FROM '+QUOTENAME(@MSDBName) +'.dbo.backupset AS bs
1128
1128
INNER JOIN '+QUOTENAME(@MSDBName) +'.dbo.backupmediafamily bmf ON bs.media_set_id = bmf.media_set_id
1129
1129
WHERE UPPER(bmf.physical_device_name)= N''NUL''
1130
1130
AND bs.is_copy_only = 0 AND bs.recovery_model <> N''SIMPLE''
1131
-
AND bs.backup_finish_date >= DATEADD(DAY, -30, SYSDATETIME())
0 commit comments