Back to results for “Migration”
SQL Server › Transparent Data Encryption

How would you migrate a TDE encrypted database to a new server, and what specific steps are required to ensure the migration succeeds?

Advanced

Answer

You would first back up the certificate and its private key from the original server, restore that certificate onto the new destination server, ensure the database master key is properly set up on the new server as well, and only then restore the actual database backup, since attempting to restore a TDE encrypted database without first properly setting up the matching certificate on the destination server will fail.
-- On the new server, restore the certificate first
CREATE CERTIFICATE MyServerCert
FROM FILE = 'C:\Backups\MyServerCert.cer'
WITH PRIVATE KEY (FILE = 'C:\Backups\MyServerCert.pvk', DECRYPTION BY PASSWORD = 'StrongPassword123!');

-- Then restore the database
RESTORE DATABASE MyDatabase FROM DISK = 'C:\Backups\MyDatabase.bak';
Real-world example A company migrating their encrypted database to a new server carefully restores the TDE certificate first, confirming it matches the original before attempting to restore the actual encrypted database backup, avoiding a failed migration.

Common follow-ups: What error occurs if you try to restore a TDE database without the matching certificate?;How do you verify the certificate on the new server actually matches the one used to encrypt the original database?