scenario, the incremental backup of SQL Server is done on a full-scale backup basis, and if recovery is needed, it is necessary to restore the full amount of backup before restoring the corresponding incremental backup file.
For example, we have a full amount of backup a database to produce 1.bak files, and then incremental backup, will produce 2.diff files.
If the recovery, restore the 1.bak, and then restore 2.diff, can be normal recovery to the original data.
But if there is another full-scale backup in this process, then the attempt to recover by 1.bak + 2.diff will fail.
Because incremental backups are incremental for the latest full-scale backups, we need to determine whether the time to generate a full-scale 1.bak backup is consistent with the latest full-scale backup time in SQL Server.
If not, the subsequent incremental backup is not based on a full-scale backup of 1.bak.
The instructions obtained are as follows:
SQLSERVER2003 and below can use osql,sqlserver2005 and above can use osql or sqlcmd (parameter $username in self-substitution statements, $password, $dbname)
Osql.exe/sqlcmd.exe-u $username-P $password-D master-q "select MAX (backup_finish_date) as ' latest Backup date ' from MS Db.. Backupset WHERE type= ' D ' and database_name = ' $dbname ' GROUP by database_name '
The results returned are as follows:
SQL Server gets the most recent full-volume backup time for the database