tsql - Find if valid full backup exists for SQL Server Database -


i'm wanting find given database whether or not valid full backup exists can used differential or trans log backups. of course it's not enough full backup exists, must able begin chain. end want eliminate backups created before recovery model change, copy backups. tsql please. no gui explanations.

i looked @ source ola hallengren's backup script , came this:

select  case when last_log_backup_lsn null 0              else 1         end log_backup_possible    sys.database_recovery_status   database_id = db_id('foobar'); 

a log backup can taken if last_log_backup_lsn not null. also, differential backup enough start taking log backups.

in other news, alluded ola hallengren's excellent maintenance scripts above. specifically, has parameter in backup stored procedure (@changebackuptype) takes care of of (so don't have re-invent wheel).


Comments