Avamar SQL Plugin Useful TSQL scripts and when to use them during troubleshooting

Summary: Commonly used TSQL scripts to troubleshoot SQL backup and restore issues.

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

1) This TSQL script generates a complete backup history over a time period.
This is useful to determine if and when specific Database was last backed up.
  • Get Entire Database Backup History including its size backed up over a certain date range.
SELECT msdb.dbo.backupset.database_name,
msdb.dbo.backupset.backup_start_date,
msdb.dbo.backupset.backup_size,
msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.type,
msdb.dbo.backupset.database_backup_lsn,
msdb.dbo.backupset.first_lsn,
msdb.dbo.backupset.last_lsn
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset
ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id 
WHERE database_name IN ('sql_database_name_here')
--and msdb.dbo.backupset.backup_finish_date between '1/20/2000' and '10/14/2022'
ORDER BY 
2 DESC,
3 DESC

This TSQL script is used to check the SQL LSN number sequence and whether the "log chain" is broken when avsql logs show "Log gap" errors.
  • The Backup LSN Information can be validated by running the following two queries.
SELECT last_lsn, type, user_name FROM msdb..backupset WHERE database_name=N'sql_database_name_here' AND type LIKE 'L' ORDER by last_lsn DESC

SELECT last_log_backup_lsn FROM sys.database_recovery_status "WHERE database_id = DB_ID(N’sql_database_name_here')"
Note: Customize the "sql_database_name_here" entries to your need.
Compare the Database LSN information returned from the above queries to what Avamar SQL Plugin stored in sqlmeta.xml file.
Article Properties
Article Number: 000207317
Article Type: How To
Last Modified: 05 Sep 2025
Version:  3
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.