Is your SQL Server backup running slow? Here’s how you can speed it up

Taking regular backups is a crucial and necessary part of an SQL database administrator’s routine job. Backup helps to safeguard SQL server database from any data loss.  Usually, an organizational database contains huge amounts of important data that the organization can by no means afford to jeopardize. Hence, irrespective of how voluminous the database is and how tedious it might be, an SQL Server database must be thoroughly backed up.

speedup SQL backup process

However, the process is not very straightforward. With an increase in the size of the database, the time taken to back it up also rises. You might very well have a backup process stretching over days. That could put everything else on hold, but frankly, which organization has the time for that? So what seems to be the solution? Some cool tips and tricks to improve SQL backup performance.

Need for Speed in SQL Backups

A single database having a size in gigabytes can have millions of rows of data. Extend that size to terabytes, and the database will contain a couple of billion rows of data occupying massive disk space and spread across multiple Filegroups. Naturally, backing up such mammoth volumes of data is going to take time. However, for any organization, time is money. Putting an SQL Server database for backing up could mean holding up other tasks on it. That means inaccessibility of the server for the users. And when it comes to work, no user would be happy wasting time to server inaccessibility even for a couple of hours, let alone days. So something needs to be done to speed up things a bit.

Techniques that can help speed up SQL Backups

There are a lot of things that you can do in order to bring down the time it takes to backup the entire SQL server database. Some helpful techniques and tips are mentioned below:

Now that we’ve taken care of the basics, let’s jump head on into the steps to speed up SQL backup through compression.

How to speed up SQL backups through compression

Step 1: The option to compress database backup is disabled by default. To enable it, you’ll need to add the word “COMPRESSION” to a T-SQL backup query in the SQL Server Management Studio (SSMS) GUI. In this GUI, you can find the Compression feature as follows:

Right click on the database to be backed up -> Tasks -> Back Up -> Options -> Compression (at the bottom).

Step 2: Once the “Compress Backup” option has been selected, you can generate the TSQL statement by clicking on the Script option.

Step 3: If you want to enable backup compression as the default option for all databases, execute the following command:

USE master
GO
EXEC sp_configure backup compression default, ‘1’;
RECONFIGURE WITH OVERRIDE

Step 4: If you’re using Solid State Disks for the backup as suggested earlier, running the above query will result in more than 1400 MB / sec being read on average for each disk (that’s roughly equivalent to reading 2 CD ROMs full of data each second).

Step 5: A feature not much talked about is the option to specify multiple file destinations to improve throughput. You can implement this to give the backup performance a further boost by running the following command:

DBCC TRACEON (3605, -1)

DBCC TRACEON (3213, -1)

BACKUP DATABASE [TPCH_1TB]

TO DISK = <filepathtodisk1>

DISK = <filepathtodisk2>

DISK = <filepathtodisk3>

DISK = <filepathtodisk4>

DISK = <filepathtodisk5>

WITH NOFORMAT, INIT, NAME = N'TPCH_1TB-Full Database Backup',

SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10

DBCC TRACEOFF (3605, -1)

DBCC TRACEOFF (3213, -1)

Step 6: As mentioned in the techniques to improve throughput, setting advanced backup parameters can add significant points to increase backup throughput.

Adding these parameters to your query isn’t tough. Just add the following snippet after the line starting with SKIP and right before the ‘DBCC TRACEOFF’ code lines:

,BUFFERCOUNT = <count>
,BLOCKSIZE = <size>
,MAXTRANSFERSIZE
GO

Note: You can use the special option TO DISK = ‘NUL’ in order to estimate how quickly data can be read from a database or Filegroup.

To sum it up

Why let SQL backup make you wait for hours together when you can reduce the time it takes with some simple steps? Do keep compression in mind and also use our helpful tips where you can to gain major perks regarding backup throughput.

Related Post

Exit mobile version