SQL Server gets the most recent full-volume backup time for the database

Source: Internet
Author: User
Tags diff

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.