WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

SQL Server · Intermediate · question 22 of 100

What are the different types of backups in SQL Server, and when should you use each type?

📕 Buy this interview preparation book: 100 SQL Server questions & answers — PDF + EPUB for $5

There are several types of backups available in SQL Server, each with its own specific purpose and benefits. The following are the most commonly used types of backups:

1. Full Backup: A full backup is a complete backup of the entire database, including all data pages and log information. It is the baseline backup for the database, and it’s used to restore the database to its original state. Full backups are typically performed regularly, such as daily or weekly, depending on the application’s requirements. A full backup can be used to restore the database to any point in time.

Example:

BACKUP DATABASE MyDatabase
TO DISK = 'C:MyBackupMyDatabase.bak'
WITH FORMAT, NAME = 'Full Backup';

2. Differential Backup: Differential backups only backup the data that has changed since the last full backup. This type of backup is useful for databases that are very large and require frequent backups, as it reduces the backup time and storage space required. Differential backups can be used to restore the database to any point in time between the current differential backup and the last full backup.

Example:

BACKUP DATABASE MyDatabase
TO DISK = 'C:MyBackupMyDatabaseDiff.bak'
WITH DIFFERENTIAL, NAME = 'Differential Backup';

3. Transaction Log Backup: Transaction log backups capture all changes made to the database since the last transaction log backup. This type of backup is important for recovery purposes, as it allows you to restore the database to a specific point in time. Transaction log backups can be performed frequently, such as every 15 minutes or 30 minutes, depending on the application’s requirements.

Example:

BACKUP LOG MyDatabase
TO DISK = 'C:MyBackupMyDatabaseLog.trn'
WITH NAME = 'Transaction Log Backup';

4. Copy-only Backup: Copy-only backups are used to create an ad-hoc backup that does not interrupt the backup sequence. This type of backup is useful when you want to create a one-time backup without affecting the regularly scheduled backups. Copy-only backups can be either a full backup or a differential backup.

Example:

BACKUP DATABASE MyDatabase
TO DISK = 'C:MyBackupMyDatabaseCopy.bak'
WITH COPY_ONLY, NAME = 'Copy-Only Backup';

5. File or Filegroup Backup: File or filegroup backups allow you to backup specific files or filegroups within a database. This type of backup is useful for databases where not all files are equally important or where specific files need to be restored. File or filegroup backups can be restored independently or in combination with other file or filegroup backups.

Example:

BACKUP DATABASE MyDatabase
FILEGROUP = 'PRIMARY'
TO DISK = 'C:MyBackupMyDatabaseFilegroup.bak'
WITH NAME = 'Filegroup Backup';

In summary, the type of backup to use depends on the database’s requirements and the recovery plan. It is recommended to have a combination of full, differential, and transaction log backups to ensure data recovery in case of a disaster.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic SQL Server interview — then scores it.
📞 Practice SQL Server — free 15 min
📕 Buy this interview preparation book: 100 SQL Server questions & answers — PDF + EPUB for $5

All 100 SQL Server questions · All topics