Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restoring database with TDE to a 2nd instance


Restoring database with TDE to a 2nd instance

Author
Message
winston Smith
winston Smith
SSC Eights!
SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)

Group: General Forum Members
Points: 973 Visits: 2040
I was unsure of how to do this so i done some googling and a few tests of my own, and although i am successful, i have a few questions. heres what i did:

On Instance 1 I created a master key, created a server cert, backed up the server cert and encrypted it with a password. I then created a db encryption key using the server cert and enabled TDE, and took a backup. no problems

use master
GO
--create master key
create master key encryption by password = 'strong_Passw0rD'
GO
--create server certificate
Create certificate ServerCert with subject = 'server cert for use with TDE'
GO
--backup server cert, encrypting it by password
Backup certificate ServerCert to file = 'C:\cert_Backups\servercert.cer'
with private key (file = 'C:\cert_Backups\servercert.key',encryption By Password = 'strong_Passw0rD')
go

use security_testing
GO
--create db encryption key which is encrypted by the serverCert
create database encryption key with algorithm = AES_128
encryption by server certificate ServerCert
GO

--enable encryption
Alter database security_testing
set encryption on
GO

--backup encrypted database
backup database security_testing
to disk = 'C:\cert_Backups\db_bak\security_testing_encrypted_bak.bak'



On instance 2, i tried to restore the backup, this failed, so i created a new server master key, and then restored the server cert and had no problems restoring the backup:

--try to restore database on 2nd instance
RESTORE DATABASE [TDE_Restore] FROM DISK = N'C:\cert_Backups\db_bak\security_testing_encrypted_bak.bak' WITH FILE = 1,
MOVE N'Security_Testing' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TDE_Restore.mdf',
MOVE N'Security_Testing_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TDE_Restore_1.LDF', NOUNLOAD, STATS = 10
GO
--cannot restore database.

--trying to restore keys first.

USE master
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'TDEtesting123'
GO

CREATE CERTIFICATE serverCert FROM FILE = 'C:\cert_Backups\servercert.cer'
WITH PRIVATE KEY (FILE = 'C:\cert_Backups\servercert.key', DECRYPTION BY PASSWORD = 'strong_Passw0rD')
GO

RESTORE DATABASE [TDE_Restore] FROM DISK = N'C:\cert_Backups\db_bak\security_testing_encrypted_bak.bak' WITH FILE = 1,
MOVE N'Security_Testing' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TDE_Restore.mdf',
MOVE N'Security_Testing_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TDE_Restore_1.LDF', NOUNLOAD, STATS = 10
GO
--Success



My question surrounds the server master key. i thought i should have to backup the server master key from instance 1 and restore it to instance 2 in order to be able to restore the server cert and thus the database. as you can see above, i dont, as i created a completely new server master key on instance 2 with a completely different password. what is the purpose of the server master key in this case?

Question 2 is where does the Service Master Key fit into all this?
Roy Ernest
Roy Ernest
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2494 Visits: 6852
If my understanding is correct, Master key just protect the private key of certificates and asymmetric keys that are present in the DB. It is the certificate that matters in TDE.
That is my understanding

-Roy
winston Smith
winston Smith
SSC Eights!
SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)SSC Eights! (973 reputation)

Group: General Forum Members
Points: 973 Visits: 2040
Roy Ernest (9/29/2009)
If my understanding is correct, Master key just protect the private key of certificates and asymmetric keys that are present in the DB. It is the certificate that matters in TDE.
That is my understanding


to protect the cert from what though? If i have the cert and the password to decrypt the cert, theres no way a master key can protect it, but the master key is still required to create the server certificate ( and prob keys in the db, have not checked this yet though).
npranj
npranj
Valued Member
Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)

Group: General Forum Members
Points: 51 Visits: 320
Master key is created at instance level and hence it is absolutely OK to create a master key for the destination database instance which you did.

The Certificate and Keys becaked up from the source database server are the ones that will be used to encrypt.
pramod.singh 40121
pramod.singh 40121
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 97
Please check the below link for restoring with server master key.

http://blogs.msdn.com/b/ai/archive/2012/09/24/enabling-tde-transparent-data-encryption-on-all-user-databases.aspx
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search