I'm trying to backup the master key for a TDE database, but SQL Server says there isn't one. It's a bit weird, but I'm sure I'm just doing something wrong. I'm sysadmin on the server, so I should be able to see everything.
This is the statement that is failing:
USE [my_db];
BACKUP MASTER KEY
TO FILE = 'C:\master_key'
ENCRYPTION BY PASSWORD = 'some_killer_password';
And the error message returned:
Msg 15151, Level 16, State 1, Line 11
Cannot find the symmetric key 'master key', because it does not exist or you do not have permission.
I've used the following to see the details about the database encryption key, and the associated certificate, however the certificate details from the sys.certificates
table is empty.
USE [my_db];
SELECT DatabaseName = d.name
, ddek.encryptor_type
, ddek.opened_date
, c.name
, c.cert_serial_number
, c.pvt_key_encryption_type_desc
, c.subject
FROM sys.dm_database_encryption_keys ddek
INNER JOIN sys.databases d ON ddek.database_id = d.database_id
LEFT JOIN sys.certificates c ON ddek.encryptor_thumbprint = c.thumbprint
WHERE d.name <> 'tempdb' /* tempdb is auto-encrypted by SQL Server */
╔══════════════╦════════════════╦═════════════════════════╦══════╦════════════════════╦══════════════════════════════╦═════════╗ ║ DatabaseName ║ encryptor_type ║ opened_date ║ name ║ cert_serial_number ║ pvt_key_encryption_type_desc ║ subject ║ ╠══════════════╬════════════════╬═════════════════════════╬══════╬════════════════════╬══════════════════════════════╬═════════╣ ║ my_db ║ CERTIFICATE ║ 2017-09-20 11:24:13.590 ║ NULL ║ NULL ║ NULL ║ NULL ║ ╚══════════════╩════════════════╩═════════════════════════╩══════╩════════════════════╩══════════════════════════════╩═════════╝
So, I can see the database encryption key in [my_db]
, and I can see it's encrypted by a certificate, but the certificate doesn't exist?