Troubleshooting Guide: Error 3009 – Could Not Insert Backup/Restore History Record in msdb
Why This Error Happens
Error 3009 occurs when SQL Server successfully completes a backup or restore operation but fails to log the corresponding metadata into the msdb database’s history tables (such as backupset, backupfile, or restorehistory). This is typically caused by insufficient disk space on the volume hosting msdb, a corrupted or oversized msdb transaction log, implicit permission issues on the msdb system tables, or msdb database corruption. Since msdb is a system database, any blocking, corruption, or growth restriction on it will prevent history logging even though the actual backup/restore data operation completes without issue.
Step-by-Step Resolution Guide
Step 1: Verify Disk Space and msdb File Growth Settings
- Check the drive hosting the msdb data and log files (typically
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) for available free space. - Run
EXEC sp_helpdb msdb;in SQL Server Management Studio (SSMS) to confirm current file size and autogrowth settings. - If space is low, free up disk space or move msdb files using
ALTER DATABASE msdb MODIFY FILEto a volume with more capacity. - Ensure autogrowth is set to a reasonable fixed MB value instead of a percentage to avoid excessive growth delays.
Step 2: Run Consistency Checks on msdb
- Open SSMS and execute
DBCC CHECKDB ('msdb') WITH NO_INFOMSGS, ALL_ERRORMSGS;to detect corruption in system tables. - Review the output for allocation or consistency errors specifically tied to
backupset,backupfile,backupmediafamily, orrestorehistorytables. - If corruption is found, restore msdb from a known good backup or engage emergency repair procedures (
REPAIR_ALLOW_DATA_LOSSonly as a last resort).
Step 3: Validate Permissions and Service Account Access
- Confirm the SQL Server service account (visible in SQL Server Configuration Manager) has full read/write access to the msdb data/log file directory.
- In SSMS, verify the login executing the backup/restore has
db_backupoperatoror sufficient rights by running:
USE msdb;
EXEC sp_helprotect NULL, NULL, NULL, 'backupset';
- Grant missing permissions using
GRANT INSERT ON dbo.backupset TO [YourServiceAccount];if gaps are identified.
Step 4: Check msdb Transaction Log Health
- Query log space usage with
DBCC SQLPERF(LOGSPACE);and filter for the msdb row. - If the log is full or in an unusual growth state, back up the msdb log file using
BACKUP LOG msdb TO DISK = 'C:\Backups\msdb_log.trn';to clear pending transactions. - Shrink the log only if necessary with
DBCC SHRINKFILE (MSDBLog, 50);after the backup completes.
Step 5: Restart SQL Server Service and Monitor Logs
- Restart the SQL Server (MSSQLSERVER) service via Services.msc or
net stop MSSQLSERVER && net start MSSQLSERVERon Windows Server 2025/Windows 11. - Immediately after restart, check the SQL Server Error Log (
SSMS > Management > SQL Server Logs) for any recurring 3009 entries tied to subsequent backup jobs.
Alternative or Verification Steps
- Run a manual test backup (
BACKUP DATABASE [TestDB] TO DISK = 'C:\Temp\test.bak';) and confirm a new row appears inmsdb.dbo.backupsetwithout triggering Error 3009. - If the issue persists after the above steps, consider rebuilding the msdb database entirely using the SQL Server Setup Repair feature (
setup.exe /ACTION=REBUILDDATABASE), though this should only be attempted after consulting Microsoft support due to its system-wide impact.