Backup encryption - SQL Server (2024)

  • Article

Applies to: Backup encryption - SQL Server (1) SQL Server

This article provides an overview of the encryption options for SQL Server backups. It includes details of the usage, benefits, and recommended practices for encrypting during backup.

Overview

Starting in SQL Server 2014 (12.x), SQL Server has the ability to encrypt the data while creating a backup. By specifying the encryption algorithm and the encryptor (a Certificate or Asymmetric Key) when creating a backup, you can create an encrypted backup file. All storage destinations: on-premises and Azure storage are supported. In addition, encryption options can be configured for SQL Server managed backup to Microsoft Azure operations, a new feature introduced in SQL Server 2014 (12.x).

To encrypt during backup, you must specify an encryption algorithm, and an encryptor to secure the encryption key. The following are the supported encryption options:

  • Encryption Algorithm: The supported encryption algorithms are: AES 128, AES 192, AES 256, and Triple DES

  • Encryptor: A certificate or asymmetric Key

Caution

It's very important to back up the certificate or asymmetric key, and preferably to a different location than the backup file it was used to encrypt. Without the certificate or asymmetric key, you can't restore the backup, rendering the backup file unusable. Certificates stored in a contained system database should also be backed up.

Restoring the encrypted backup: SQL Server restore doesn't require any encryption parameters to be specified during restores. It does require that the certificate or the asymmetric key used to encrypt the backup file is available on the instance that you're restoring to. The user account performing the restore must have VIEW DEFINITION permissions on the certificate or key. If you're restoring the encrypted backup to a different instance, you must make sure that the certificate is available on that instance.
The sequence to restore an encrypted database to a new location is to:

  1. BACKUP CERTIFICATE (Transact-SQL) in the old database
  2. CREATE MASTER KEY (Transact-SQL) in the new location master database
  3. CREATE CERTIFICATE (Transact-SQL) from the backup certificate of the old database imported to a location on the new server
  4. Restore a database to a new location (SQL Server)

If you're restoring a backup from a TDE encrypted database, the TDE certificate should be available on the instance you're restoring to. For more information, see Move a TDE protected database to another SQL Server.

Benefits

  1. Encrypting the database backups helps secure the data: SQL Server provides the option to encrypt the backup data while creating a backup.

  2. Encryption can also be used for databases that are encrypted using TDE.

  3. Encryption is supported for backups done by SQL Server managed backup to Microsoft Azure, which provides additional security for off-site backups.

  4. This feature supports multiple encryption algorithms up to AES 256 bit. This gives you the option to select an algorithm that aligns with your requirements.

  5. You can integrate encryption keys with Extensible Key Management (EKM) providers.

Prerequisites

The following are prerequisites for encrypting a backup:

  1. Create a database master key for the master database: The database master key (DMK) is a symmetric key that is used to protect the private keys of certificates and asymmetric keys that are present in the database. For more information, see SQL Server and Database Encryption Keys (Database Engine).

  2. Create a certificate or asymmetric key to use for backup encryption. For more information on creating a certificate, see CREATE CERTIFICATE (Transact-SQL). For more information on creating an asymmetric key, see CREATE ASYMMETRIC KEY (Transact-SQL).

    Important

    Only asymmetric keys residing in an Extensible Key Management (EKM) are supported.

Limitations

The following are restrictions that apply to the encryption options:

  • If you're using asymmetric key to encrypt the backup data, only asymmetric keys residing in the EKM provider are supported.

  • SQL Server Express and SQL Server Web don't support encryption during backup. However restoring from an encrypted backup to an instance of SQL Server Express or SQL Server Web is supported.

  • Previous versions of SQL Server can't read encrypted backups.

  • Appending to an existing backup set option isn't supported for encrypted backups.

Permissions

The account that does backup operations on an encrypted database requires specific permissions.

  • db_backupoperator database level role on the database being backed up. This is required regardless of encryption.

  • VIEW DEFINITION permission on the certificate in master database.

    The following example grants the appropriate permissions for the certificate.

    USE [master]GOGRANT VIEW DEFINITION ON CERTIFICATE::[<SERVER_CERT>] TO [<db_account>]GO

Note

Access to the TDE certificate isn't required to back up or restore a TDE protected database.

Backup encryption methods

The following sections provide a brief introduction to the steps to encrypting the data during backup. For a complete walkthrough of the different steps of encrypting your backup using Transact-SQL, see Create an Encrypted Backup.

Use SQL Server Management Studio

You can encrypt a backup when creating the backup of a database in any of the following dialog boxes:

  1. Back Up Database (Backup Options Page) On the Backup Options page, you can select Encryption, and specify the encryption algorithm and the certificate or asymmetric key to use for the encryption.

  2. Using Maintenance Plan Wizard When you select a backup task, on the Options tab of the Define Backup ()Task page, you can select Backup Encryption, and specify the encryption algorithm and the certificate or key to use for the encryption.

Use Transact-SQL

Following is a sample Transact-SQL statement to encrypt the backup file:

BACKUP DATABASE [MYTestDB]TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup\MyTestDB.bak'WITH COMPRESSION, ENCRYPTION ( ALGORITHM = AES_256, SERVER CERTIFICATE = BackupEncryptCert ), STATS = 10GO

For the full Transact-SQL statement syntax, see BACKUP (Transact-SQL).

Use PowerShell

This example creates the encryption options and uses it as a parameter value in Backup-SqlDatabase cmdlet to create an encrypted backup.

$encryptionOption = New-SqlBackupEncryptionOption -Algorithm Aes256 -EncryptorType ServerCertificate -EncryptorName "BackupCert"Backup-SqlDatabase -ServerInstance . -Database "<myDatabase>" -BackupFile "<myDatabase>.bak" -CompressionOption On -EncryptionOption $encryptionOption

Recommended practices

Create a backup of the encryption certificate and keys to a location other than your local machine where the instance is installed. To account for disaster recovery scenarios, consider storing a backup of the certificate or key to an off-site location. You can't restore an encrypted backup without the certificate used to encrypt the backup.

To restore an encrypted backup, the original certificate used when the backup was taken with the matching thumbprint should be available on the instance you're restoring to. Therefore, the certificate shouldn't be renewed on expiry or changed in any way. Renewal can result in updating the certificate triggering the change of the thumbprint, therefore making the certificate invalid for the backup file. The account performing the restore should have VIEW DEFINITION permissions on the certificate or the asymmetric key used to encrypt during backup.

Availability Group database backups are typically performed on the preferred backup replica. If you restore a backup on a replica other than where the backup was taken from, ensure that the original certificate used for backup is available on the replica you're restoring to.

If the database is TDE enabled, choose different certificates or asymmetric keys for encrypting the database and the backup to increase security.

Related content

  • Create an Encrypted Backup
  • Extensible Key Management Using Azure Key Vault (SQL Server)
  • Backup overview (SQL Server)
Backup encryption - SQL Server (2024)

FAQs

How to backup encryption in SQL Server? ›

You can encrypt a backup when creating the backup of a database in any of the following dialog boxes: Back Up Database (Backup Options Page) On the Backup Options page, you can select Encryption, and specify the encryption algorithm and the certificate or asymmetric key to use for the encryption.

What is the best backup strategy in SQL Server? ›

10 Best Practices for SQL Server Backups
  • Full Backup. A full backup captures the entire database, including all the data and schema objects. ...
  • Differential Backup. ...
  • Transaction Log Backup. ...
  • File or File Group Backup. ...
  • Establish a Backup Schedule. ...
  • Automate Backups. ...
  • Implement Data Retention Policies. ...
  • Store Backups Securely.
Oct 20, 2023

Should I encrypt SQL Server database? ›

One solution is to encrypt sensitive data in a database and use a certificate to protect the keys that encrypt the data. This solution prevents anyone without the keys from using the data. But you must plan this kind of protection in advance. TDE does real-time I/O encryption and decryption of data and log files.

How to check if SQL backup is encrypted? ›

Open a new query window in SSMS connected to a SQL Instance running SQL Backup. If the IsEncrypted value is 0 - The backup file is a SQL Backup file, but contains no encryption. If the IsEncrypted value is 1 - The backup file is a SQL Backup file, but contains no encryption.

Where are SQL Server encryption keys stored? ›

To prevent unauthorized decryption, TDE stores the encryption keys in a security module external to the database. TDE performs real-time I/O encryption and decryption of the data and log files.

How to check encryption in SQL Server? ›

How to tell if encryption is working?
  1. Open a new query window in SQL Server Management Studio (SSMS) and connect to the SQL Server instance.
  2. Execute the following T-SQL command to check the value of encrypt_option column. For encrypted connections the value will be TRUE .
May 11, 2023

What are the main 3 types of backups in SQL? ›

Microsoft SQL Server allows three basic types of SQL Server backup:
  • Full backup.
  • Differential backup.
  • Transaction log backup.
Jan 5, 2021

What is the most reliable backup method? ›

The most reliable data storage and backup methods include cloud storage services like Amazon S3, Google Cloud Storage, and Microsoft Azure, offering scalability and redundancy. Additionally, using external hard drives or network-attached storage (NAS) devices for local backups provides quick access to data.

How can I make SQL Server backup faster? ›

Beg, borrow, or buy at least two disk drives in addition to the drive your SQL Server data and log files are on. Create a reasonably big database with data and log files on the fast SATA SSD. Record the speed of backup and verify on only the second backup to each, i.e. after caches have been filled.

What is a disadvantage of using encryption SQL? ›

Disadvantages. Database encryption requires tight integration with the database and may need to be purchased separately from a database vendor. Data type of the field being encrypted. References to and queries of the encrypted field(s) will have to be modified to limit access.

Should database backups be encrypted? ›

To ensure recoverability after a disruption, data backup encryption is vital. The key to data integrity is reliability and trust at all times. Backups are a vital part of data and application recoverability and must always be secure. Encryption is essential to data protection, and backups are no exception.

What is the major issue with database encryption? ›

Encrypting an entire database should be done with caution since it can result in a serious performance impact. It is, therefore, wise to encrypt only individual fields or tables. Encrypting data-at-rest protects the data from physical theft of hard drives or unauthorized file storage access.

How do I know if SQL backup is valid? ›

During the database restore process, SQL Server recalculates the CHECKSUM value for each page and matches with the CHECKSUM value written during the backup. If both values are similar, it shows that the database backup is valid.

How to encrypt data in SQL Server database? ›

We use the following steps for column level encryption:
  1. Create a database master key.
  2. Create a self-signed certificate for SQL Server.
  3. Configure a symmetric key for encryption.
  4. Encrypt the column data.
  5. Query and verify the encryption.
Jan 14, 2020

How do I check data integrity of backup? ›

To verify the integrity and usability of your backups, you should calculate and compare the checksums of your backup files and original data. Additionally, you should encrypt your backups with secure encryption keys and test them regularly to guarantee that you can decrypt them when needed.

How to store encrypted data in SQL Server? ›

Configuring Always Encrypted with SQL Complete
  1. Create a new database and a table.
  2. Insert columns with values into the table.
  3. Retrieve data from the table.
  4. Create a column master key.
  5. Create a column encryption key.
  6. Encrypt columns for the created table.
Mar 26, 2021

How to backup SQL Server security logins? ›

Open SQL Server Management Studio. Expand Security, and expand the list of Logins. Right-click the login you want to create a backup script for, and then select Script Login as. Select CREATE To, and then select one of New Query Editor Window, File, or Clipboard to select a destination for the script.

How do I backup my Reporting Services encryption key? ›

Back up encryption keys -Report Server Configuration Manager (Native Mode)
  1. Start the Report Server Configuration Manager, and then connect to the report server instance you want to configure.
  2. Click Encryption Keys, and then select Back Up.
  3. Type a strong password.
  4. Specify a file to contain the stored key. ...
  5. Select OK.
Mar 22, 2023

How to take an encrypted database backup in MySQL? ›

Backing up a database server with encrypted InnoDB tablespaces. For MySQL Enterprise Backup to backup encrypted InnoDB tablespaces, the operating system user that runs MySQL Enterprise Backup must have write permission for the keyring file on the server if the keyring_aws plugin is used on it.

Top Articles
Plafond de retrait - Définition
IRS e-file shutdown and opening day dates
Radikale Landküche am Landgut Schönwalde
Best Pizza Novato
It may surround a charged particle Crossword Clue
Angela Babicz Leak
craigslist: kenosha-racine jobs, apartments, for sale, services, community, and events
Paris 2024: Kellie Harrington has 'no more mountains' as double Olympic champion retires
Find All Subdomains
DL1678 (DAL1678) Delta Historial y rastreo de vuelos - FlightAware
Does Publix Have Sephora Gift Cards
Globe Position Fault Litter Robot
Knaben Pirate Download
Rapv Springfield Ma
Palace Pizza Joplin
Mlb Ballpark Pal
‘Accused: Guilty Or Innocent?’: A&E Delivering Up-Close Look At Lives Of Those Accused Of Brutal Crimes
Superhot Unblocked Games
United Dual Complete Providers
Craigslist Pets Sac
Dit is hoe de 130 nieuwe dubbele -deckers -treinen voor het land eruit zien
10-Day Weather Forecast for Florence, AL - The Weather Channel | weather.com
50 Shades Darker Movie 123Movies
Delaware Skip The Games
Christina Steele And Nathaniel Hadley Novel
Is A Daytona Faster Than A Scat Pack
Living Shard Calamity
Obituaries Milwaukee Journal Sentinel
30+ useful Dutch apps for new expats in the Netherlands
Viduthalai Movie Download
Deepwoken: Best Attunement Tier List - Item Level Gaming
Pdx Weather Noaa
King Soopers Cashiers Check
Kaiser Infozone
The Menu Showtimes Near Amc Classic Pekin 14
Wasmo Link Telegram
Most popular Indian web series of 2022 (so far) as per IMDb: Rocket Boys, Panchayat, Mai in top 10
Smartfind Express Henrico
Callie Gullickson Eye Patches
The Conners Season 5 Wiki
Academic Notice and Subject to Dismissal
Makes A Successful Catch Maybe Crossword Clue
Florida Lottery Powerball Double Play
Kjccc Sports
Air Sculpt Houston
Pas Bcbs Prefix
The Plug Las Vegas Dispensary
Sj Craigs
Latest Posts
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 5611

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.