Sql-server – What all files are required for restoration process of SQL Server in Full + Diff + Transactional backup policy

backuprestoresql server

I am reading about different types of backup policy in sql server. I am not clear with backup policy for Full + Differential + Transactional backiup

My main attention is towards what all files would be required at the time of restoration. As per the diagram given on SQL Authority, it seems like I need all the files i.e.

last full backup file 1 + log file 1.1 + log file 1.2 + differential 1.1 + log file 1.4 + log file 1.5 + Differential 1.2 + ...all log files..

or did i interpret it wrong and I would need
last full backup file + differential 2 + log file 2.1 + log file 2.2....

EDIT:

What is contained in differential backup, is it just mdf + ndf backup or ldf + mdf + ndf backup since last full backup was taken?

Best Answer

For example, we have the database "test" and we make a full backup every 24 hours, differential backup every 6 hours and backup your transaction log every hour. But for this schedule your database should run with full or bulk-logged recovery model. So, what should we do when the failure occurs? First of all, we have to restore our last full backup. Full database backup consists of a backup copy that containing all data files and active part of the transaction log.

RESTORE DATABASE test FROM DISK = 'd:/test.bak' WITH NORECOVERY, REPLACE

The Next step is to restore the last differential database backup, that containing all changes made to the database since the last full backup and active part of the transaction log.

RESTORE DATABASE test FROM DISK = 'd:/test_diff.bak' WITH NORECOVERY

And finally we can restore all transaction log backups. Transaction log backup contains all log records that haven’t been backed up, up to the last log record that exists at the time of backup completion. We have to restore all transaction log backups that have been made after the last differential backup according to their log sequence number.

RESTORE LOG test FROM DISK = 'd:/test_log59.bak' WITH NORECOVERY
RESTORE LOG test FROM DISK = 'd:/test_log60.bak' WITH NORECOVERY

And the last one

RESTORE LOG test FROM DISK = 'd:/test_log61.bak' WITH RECOVERY