By:Rajendra Gupta | Last Updated: 2018-12-14 || Related Tips:More > Professional Development Interview Questions DBA
ProblemI am preparing a SQL Server DBA interview question and answer series that will help prepare professionals for basic and advanced questions. In this tip, we will start with the questions and answers related to SQL Server backups for both new and experienced professionals.
SolutionIn this tip, let's start with questions related to backups in SQL Server. Before going to an interview, be sure to review the below links as a starting point.
SQL Server Backup Tips SQL Server Backup Tutorial SQL Server Backup Overview Recovery model in SQL Server Backup and Restore of SQL server databases Q1. What is a SQL Server database backup and why are they needed?Answer: In SQL Server, a database backup is a point in time copy of database data and code that we can use to restore and recover the data in case of disaster, failure or any requirement where the database backup needs to be restored to another environment.
An effective SQL Server database backup strategy is important to recover from any disaster, which could negatively impact the application or business.
Additional Resources:
Types of SQL Server backups Q2. How many types of SQL Server database backups are there?Answer: In SQL Server, we can issue the following types of database backups:
Full Backup Differential backup Log Backup Copy-Only Backup Filegroup Backup Partial BackupAdditional Resources:
Types of SQL Server backupsQ3. What is a full SQL Server database backup and explain the internal process performed?
Answer: A full backup is a complete point in time version of the data and code. It allows the DBA to restore back to that point in time for recovery. Full backups are needed prior to both differential and transaction log backups.
SQL Server follows the below steps during a BACKUP operation:
A full database backup forces a database checkpoint to flush all data to disk. The backup process reads the data pages and writes them to the backup file. Once the data reading operation is complete, it reads the Transaction Log. The full database backup does not contain all of the records from the transaction log. Instead, it chooses only those records that are necessary to make the restored copy of the database transaction consistent. Those records begin either from the latest active transaction or from the checkpoint created by the backup. The process writes to the system tables in the MSDB database including the Backup LSN and backup history.Additional Resources:
SQL Server full backupsQ4. Suppose a SQL Server update transaction started before the full backup, it made changes after the full backup checkpoint and transactions were committed before the full backup. In this case, explain which data would be included in the full backup.
Answer: The full backup includes all transaction log records starting from the latest active transaction. This implies that the full backup includes the whole transaction with all changes that were made after the checkpoint to apply those changes during the database recovery process.
Additional Resources:
Understanding SQL Server Log Sequence Numbers for BackupsQ5. Explain the above scenario, if a transaction committed before starting the full SQL Server database backup.
Answer: In this case, once the full backup initiates the checkpoint process, all the changes made by the transaction were applied with the checkpoint so the backup will contain transaction log records added after the checkpoint.
Additional Resources:
Understanding SQL Server Log Sequence Numbers for Backups Q6. Which SQL Server database recovery models are supported with a full database backup?Answer: Full SQL Server database backups are supported by all available recovery models:
Simple Full Bulk-loggedAdditional Resources:
Recovery Models Simple Recovery Model Full Recovery Model Bulk Recovery Model Understanding SQL Server recovery models and transaction log Q7. What is a SQL Server differential backup?Answer: SQL Server differential database backups contain only extents that have changed since the last full backup. The changes are denoted by flipping a bit at the extent level to determine if the extent needs to be backed up or not.
Additional Resources:
Differential Backups SQL Server 2017 differential backup changes Q8. How do SQL Server differential backups work internally? Answer: SQL Server stores data in 8 KB pages and an extent is comprised of eight pages. Each Global Allocation Map interval (GAM interval) covers 64,000 extents and has a special database page called a differential character map (DCM). The DCM tracks which extent has changed since the last full backup. A SQL Server