Microsoft SQL Server 2008 is still one of the most popular corporate database engines, and it has a lot of backup types supported. Let’s briefly remember all of these backup types and find out how to perform the most useful ones. After reading this post, you will know how to backup a database in SQL Server 2008 using query language or SQL Management Studio GUI.
Backup Types Overview
Microsoft SQL Server has five backup types supported: full and differential, transaction- and tail-logs backup, and copy backup. But the last two ones are quite specific, so we will shortlist three of them:
- Full backup contains all database (DB) data on the moment the backup has finished, so it doesn’t allow point-in-time restoration. After a successful full backup runs, transaction logs are truncated.
- Differential backup is based on the most recent full data backup and contains only the data changed since the last full run. It requires less time to perform the back up.
- Transaction logs (T-Logs) backup contains every transaction made in SQL since the last full or differential backup. Using log backups allows you to create a DB backup every hour or even minute - that is important for core business DBs.
Please remember that SQL backup and recovery scenarios available are restricted by the database recovery mode selected - it controls transaction logs management. There are generally three types of recovery mode: Simple, Full, and Bulk logged. If choosing to create a T-Logs backup, you should set the Full recovery model for the given database.
Now let’s take a look at how to perform such backup types.
Easiest way to perform any backup in Microsoft SQL Server is using query language. You should right-click root view in the navigation tree of SQL Management Studio, and select New Query. Then paste a script and click Execute on the toolbar.
Here is the script to create a full database backup:
USE TestDB; GO BACKUP DATABASE TestDB TO full_backups WITH COMPRESSION, DESCRIPTION = 'Sample full backup', NAME = 'Set of FULL backups'; GO
You may notice full_backups as a backup target. It is a logical “backup device” representing a particular file on the HDD. You need to create one or more “devices” for any backup type described below. Use this command to create one:
BACKUP DATABASE TestDB TO diff_backups WITH DIFFERENTIAL; GO
Add DIFFERENTIAL as an option next to the WITH operator if need to create a SQL Server 2008 differential backup:
If you prefer GUI, then open SQL Management studio, navigate to the target database and choose Tasks - Back Up… in the context menu:
In the Back Up database screen, choose Full as a backup type and click Add at the screen bottom to add a backup device:
If you need to create a SQL Server 2008 differential backup - use Differential in the same drop-down menu. We suggest to use separate backup devices for every backup type. It allows you to manage backup storage more efficiently and simplifies navigation over the set of files.
After the backup job is completed, you can find resulting data in the Media Contents section of the particular backup device’s context menu.
Note: you can also automate such tasks using the SQL Server Agent feature - it allows you to create a repetitive task using a backup job dialog or query script
Transaction Logs Backup
Before creating the first T-Logs backup, please check if your target database uses the Full Recovery model. Otherwise, your backups can not be consistent since the SQL engine will keep only a few log files at once by automatically deleting the oldest ones.
Perform transaction logs backup using the query script below:
BACKUP LOG TestDB TO logs_backups; GO
You can achieve the same using GUI by selecting Transaction Log type in the drop-down menu of the backup dialog seen above:
Do not forget to add a separate backup device for the T-Logs backup type.
Microsoft SQL Server has a flexible backup model, allowing you to keep the balance of time spent to backup and speed of data recovery. In most cases you should create a full backup weekly with a set of daily differential backups. If your company needs a better RTO/RPO, consider using T-Logs backup as well.
CloudBerry Backup for MS SQL Server supports all backup types described, so you can try it for free and check whether it covers your business needs!