File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,9 +131,19 @@ public List<BackupMetadata> RecentBackups()
131131 {
132132 // find most recent full backup LSN across all replica servers
133133 var fullBackupLsnBag = new ConcurrentBag < decimal > ( ) ;
134- _listener . ForEachAgInstance ( s => fullBackupLsnBag . Add ( s . Database ( Name ) . MostRecentFullBackupLsn ( ) ) ) ;
134+ _listener . ForEachAgInstance ( s =>
135+ {
136+ try
137+ {
138+ fullBackupLsnBag . Add ( s . Database ( Name ) . MostRecentFullBackupLsn ( ) ) ;
139+ }
140+ catch { }
141+ } ) ;
135142
136143 // find all backups in that chain
144+ if ( fullBackupLsnBag . IsEmpty )
145+ throw new Exception ( $ "Could not find any full backups for DB '{ Name } '") ;
146+
137147 var databaseBackupLsn = fullBackupLsnBag . Max ( ) ;
138148 var bag = new ConcurrentBag < BackupMetadata > ( ) ;
139149 _listener . ForEachAgInstance ( s => s . Database ( Name ) . BackupChainFromLsn ( databaseBackupLsn )
Original file line number Diff line number Diff line change @@ -131,8 +131,13 @@ public decimal MostRecentFullBackupLsn()
131131 using var reader = cmd . ExecuteReader ( ) ;
132132 if ( ! reader . Read ( ) )
133133 throw new Exception ( "MostRecentFullBackup SQL found no results" ) ;
134+
135+ var lsnValue = reader [ "most_recent_full_backup_checkpoint_lsn" ] ;
134136
135- return ( decimal ) reader [ "most_recent_full_backup_checkpoint_lsn" ] ;
137+ if ( lsnValue == DBNull . Value )
138+ throw new Exception ( "MostRecentFullBackup SQL found no results" ) ;
139+
140+ return ( decimal ) lsnValue ;
136141 }
137142
138143 public List < BackupMetadata > BackupChainFromLsn ( decimal checkpointLsn )
You can’t perform that action at this time.
0 commit comments