-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDE Script
61 lines (39 loc) · 1.74 KB
/
TDE Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* step to folLow
create a databasese master key of the master database
create a backup certificate
backup the database
*/
-- create a databasese master key of the master database \ CHK MASTER DB > SECURITY | CERTIFICATE
create master key encryption by password = 'Password@1.' -- master db must be selected
-- create a backup certificate
create certificate myTestCert with subject = 'mysubjectline'
-- backup the database
backup database test to disk = 'c:\path\tesk.bak'
with encryption (algorithm = AES_256, SERVER CERTIFICATE = myTestCert)
-- backup cert in dthe source old database
backup certificate myTestCert to file = 'c:\path\Test_db_certificate.cert'
with private key (file = 'c:\path\Test_dbkey.key',
encryption by password = 'Password@1.')
/*
you are now in the ssms of the other instance.
to restore encrypted Backup | u will need the cert and the key and the .bak of the db in d new loaction
Copy to d loaction where u need the new cert
- u need the certificate that is used to encrypt the backup file and shle be available on the instance dt u r restoring ur backup file
- u the user acct performing d restore must have VIEW DEFINITION permission on the cert/key
steps
backup cert in d old database
create master key in d new location master db
create certificate from the backup cert of source
restore a db to a new location
*/
-- create master key in d new location
create master key encryption by password = 'Password@1.'
-- create certificate from the backup cert of source
USE MASTER
GO
CREATE CERTIFICATE myTestCert
FROM FILE = 'C:\path\Test_db_certificate.cert'
WITH PRIVATE KEY (FILE = 'C:\path\Test_dbkey.key',
DECRYPTION BY PASSWORD = 'Password@1.' );
-- Restore a DATABASE
restore database test from disk = 'c:\path\test.bak'