Backing up a SQL Server Certificate

It’s important to backup SQL Server Certificates, but only if you’re using them really.

If for example, your SQL Server database backups are encrypted and you need to restore it on another server, then you will need both the certificate and private key that was used.

This post is a guide on backing up a SQL Server certificate, ensuring we have a copy of the certificate and private keys.


Backup a SQL Server Certificate

Check your existing server certificates by querying sys.certificates, you’ll need the certificate name.

Use Master  
GO  
	SELECT name, pvt_key_encryption_type_desc, subject, start_date, expiry_date, key_length
	FROM sys.certificates
GO
SQL Server Select Sys.Certificates

Backup certificate (Microsoft Docs – Backup Options) – amending file paths & password.

BACKUP CERTIFICATE AT_Backup_Cert TO FILE ='C:\Temp_MSSQL_Backups\mssql_at_backup_cert.cer'  
      WITH PRIVATE KEY (   
		FILE ='C:\Temp_MSSQL_Backups\mssql_at_backup_key.pvk',  
		ENCRYPTION BY PASSWORD ='Str0ng3P4sSw0rd!' ) 

Then, move those files into a safe space.



Comments

One response to “Backing up a SQL Server Certificate”

  1. […] I have another post to guide through a certificate backup here. […]

Leave a Reply

Your email address will not be published. Required fields are marked *