"Could not insert a backup or restore history/detail record in the msdb database" While restoring msdb
Violation of PRIMARY KEY constraint 'PK__backupse__21F79AAB0E391C95'. Cannot insert duplicate key in object 'dbo.backupset'. The duplicate key value is (60979).


This might happen if someone have done a reseed on the dbo.backupset.

From table definition :

PK__backupse*  --> clustered, unique, primary key located on PRIMARY --> backup_set_id

To fix that error :

--- get the max backup set id from the backupset table 

    SELECT MAX(backup_set_id) + 1 FROM msdb.dbo.backupset

 --- then reseed it

   dbcc checkident('dbo.backupset', RESEED, VALUE_FROM_ABOVE)


Now run DBCC CHECKDB('msdb') WITH NO_INFOMSGS, ALL_ERRORMSGS to see if everything returns fine.


  Msg 8921, Level 16, State 1, Line 1
  Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors.


Try running DBCC CHECKDB with TABLOCK hint + make sure that the drive tempdb resides has enough space and tempdb is not having restrictive growth (autogrowth OFF).

Lastly,


  Msg 2515, Level 16, State 1, Line 1
  The page (1:1044), object ID 60, index ID 1, partition ID 281474980642816, allocation unit ID 281474980642816 (type In-row data) has been modified, but is not marked as modified in the differential backup bitmap.
  CHECKDB found 0 allocation errors and 1 consistency errors in table 'sys.sysobjvalues' (object ID 60).


If you run DBCC CHECKDB('msdb') WITH TABLOCK, NO_INFOMSGS, ALL_ERRORMSGSand still it gives error, then its most likely a problem with your IO subsystem. Try to check windows event logs.

Have Page checksums enabled. Also, take a full backup of msdb (which will reset differential bitmap) and then run DBCC CHECKDB('msdb') WITH TABLOCK, NO_INFOMSGS, ALL_ERRORMSGS

In an unlikely event, you should try going backward and find a good backup to restore.