Changes for page sql-tde
Last modified by Nikhil Singh on 2026/07/03 08:32
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 1 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,305 +1,363 @@ 1 -= **1. StepsforImplementingTransparentData Encryption(TDE) FROM SQL Server**=1 += TDE(backup from smss to azure) = 2 2 3 3 4 - Thisdocument outlines the process of **encrypting SQL Server databases**using **TransparentData Encryption(TDE)** and backing them up to **Azure Storage**. TDE ensures data at rest is encrypted,leveraginga**MasterKey (MK)**, **TDE Certificate**, and**DatabaseEncryptionKey (DEK)** for encryption.4 +1 Create master key in master database (set master key) 5 5 6 - Theprocessalso includes creating a **credential**forsecurebackup to **Azure Blob Storage**, providing a scalableand secure solutionfor storing encrypteddatabasesin the cloud.6 +2 Create TDE certificate (encrypted by MK) 7 7 8 +3 Backup the Certificate and private key, By encryption with a password ( did not do it in this case due to storage blog problems) 8 8 9 - [[image:image-20250305152543-1.png]]10 +4 Choose DB to create the DEK ,Create database encryption key (DEK) with algorithm ( AES= 256) and encryption by certificate 10 10 12 +5 Set encryption on for the database 11 11 12 -**~1. Create a Master Key in the master Database** 13 -The first step is to create a **Master Key** in the master database. This key will be used to encrypt other cryptographic objects, such as certificates and symmetric keys, within SQL Server. 14 +-- 6 Create a new credential with the SAS token 15 +CREATE CREDENTIAL [https://zagpebslab.blob.core.windows.net/sql-backups] 16 +WITH IDENTITY = 'SHARED ACCESS SIGNATURE', 17 +SECRET = 'sp=racwdli&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=kBFwlj5S5eqBEE32LM1EFebBY0W94uEFiwOXo3R0yt4%3D'; 18 +Go-- 14 14 20 +--7 -- 15 15 16 -**2. Create a TDE Certificate (Encrypted by the Master Key)** 17 -Next, generate a **TDE certificate** that will be used to encrypt the **Database Encryption Key (DEK)**. This certificate is encrypted by the **Master Key** created in step 1, providing an additional layer of security. 22 +{{code language="sql"}} 23 +Perform the database backup with the provided parameters 24 +EXECUTE dba.dbo.DatabaseBackup 25 + @Databases = 'dba', Replace with your database name 26 + @URL = 'https://zagpebslab.blob.core.windows.net/sql-backups', Azure Blob Storage URL 27 + @BackupType = 'Full', Full backup 28 + @CopyOnly = 'Y', Copy-only backup to avoid breaking backup chain 29 + @Compress = 'Y', Compress the backup 30 + @Verify = 'N'; No verification of backup 31 +GO 32 +{{/code}} 18 18 34 +The backup was unable to be done from smss to azure ( the MI does not support encrypted DBs to be backed up from smss to azure) 19 19 20 -**3. Choose the Database to Create the Database Encryption Key (DEK)** 21 -For the selected database, create the **Database Encryption Key (DEK)**. The DEK will be encrypted by the **TDE certificate** and will use the **AES-256 encryption algorithm** to ensure data is securely encrypted at rest. 36 +We have unencrypted a database and backed it up from ssms to azure blob successfully 22 22 23 23 24 -**4. Enable Encryption for the Database** 25 -Once the **DEK** has been created, enable **TDE** for the database. This ensures that all data written to the database is automatically encrypted at rest, providing full protection for sensitive information. 39 +Conclusion: Can be done with and unencrypted DB but not with an Encrypted one> 26 26 27 27 28 -**5. Create a Credential with a SAS Token** 29 -Finally, create a **credential** that allows SQL Server to access Azure Blob Storage. This credential is created using a **Shared Access Signature (SAS) token**, which ensures secure and authenticated access to the storage account for backup purposes. 30 30 31 -{{code language="sql"}} 32 -drop credential [https://zagpebslab.blob.core.windows.net/sql-backups] 33 -CREATE CREDENTIAL [https://zagpebslab.blob.core.windows.net/sql-backups] 34 -WITH IDENTITY='SHARED ACCESS SIGNATURE' 35 -, SECRET = 'sp=racwdli&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=kBFwlj5S5eqBEE32LM1EFebBY0W94uEFiwOXo3R0yt4%3D' 36 -GO 37 - 38 -{{/code}} 39 39 40 40 41 -** ~ 6.UseaStoredProcedure to Back UptoAzureStorage Account**45 += **Using TDE directly from azure portal** = 42 42 43 -{{code language="sql"}} 44 -EXECUTE dba.dbo.DatabaseBackup 45 -@Databases = 'dba', 46 -@URL = 'https://zagpebslab.blob.core.windows.net/sql-backups', 47 -@BackupType = 'Full', 48 -@CopyOnly = 'Y', 49 -@Compress = 'Y', 50 -@Verify = 'N' 51 -{{/code}} 52 52 53 -=== === 48 +===== 1 Go to azure key vault ( DemoTestRudi) to generate a key ===== 54 54 55 -=== Conclusion: Backup to Azure Storage Account with TDE Encrypted Databases === 56 56 57 - Theattempttobackup an **encrypted database**(with Transparent Data Encryption - TDE) from **SQL Server Management Studio(SSMS)** to an Azure Storage Account was unsuccessful. This issue arises because**Azuredoesnot permit TDE-encrypted databasesto be backed up directly to Azure Storage using SSMS**.51 +- Go to keys and click generate 58 58 59 - However,afterdecrypting the database, we were able tosuccessfully back it up to the AzureStorage Account via SSMS. This confirms that **backups can beperformed on an unencrypted database**, but **not on an encrypted database**.53 +- Name your key (mysqlmikey) 60 60 55 +- Choose a key type (RSA) 61 61 57 +-Choose RSA key size (2048-bit) 62 62 59 +Note: 63 63 61 +* switching from 2048-bit RSA to 4096-bit RSA for TDE will affect performance, but the actual impact might be minor, especially on modern hardware and typical workloads. 62 +* **It will likely affect CPU usage** more than disk I/O, and the impact might be more noticeable during key management operations (key generation, encryption, etc.). 63 +* If your database is not under heavy load and your hardware can handle the extra processing, the trade-off for better security may be worth it. 64 64 65 - =**2. EnablingTransparent Data Encryption (TDE) Using AzureKey Vault** =65 +- Click create 66 66 67 67 68 - **Introduction:** This document outlines the process of enabling**Transparent Data Encryption (TDE)** on an **Azure SQL Managed Instance (SQL MI)** using a **Customer-Managed Key (CMK)** stored in **Azure Key Vault**.The encryptionis managed usingan asymmetric key from **Azure Key Vault**, ensuring thatall datawithin the SQL ManagedInstance is encrypted using a strong encryption algorithm.68 +[[image:image-20250228120622-1.png||height="236" width="542"]] 69 69 70 70 71 -===== **1.GenerateaKeyin Azure Key Vault**=====71 +===== 2 Enable TDE ===== 72 72 73 73 74 - **-NavigatetoAzureKeyVault:**74 +- Go to your Managed instance ( sqlmi-ebs-lab) 75 75 76 - *Gotothe**Azure Portal**and select**Key Vault**(DemoRudiTest).76 +- Click on security and choose Transparent data encryption 77 77 78 - **-Generate aNewKey:**78 +- Select the type of managed key ( Customer-managed key0 79 79 80 - *Gotothe**Keys**sectionandclick**Generate**tocreatea newkey.80 +- Select the key from the key vault we generated in the key vault( mysqlmikey) 81 81 82 - **-ConfigureKeySettings:**82 +- Make the key the default TDE protector 83 83 84 -* **Name the Key**: Choose a name for your key, e.g., mysqlmikey. 85 -* **Key Type**: Select **RSA** as the key type. 86 -* **RSA Key Size**: Choose an **RSA key size** of **2048-bit**. (optional) 84 +-Click save 87 87 88 - Note: 89 89 90 -* switching from 2048-bit RSA to 4096-bit RSA for TDE will affect performance, but the actual impact might be minor, especially on modern hardware and typical workloads. 91 -* **It will likely affect CPU usage** more than disk I/O, and the impact might be more noticeable during key management operations (key generation, encryption, etc.). 92 -* If your database is not under heavy load and your hardware can handle the extra processing, the trade-off for better security may be worth it. 87 +[[image:image-20250228122106-2.png||height="251" width="511"]] 93 93 94 -**- Create the Key:** 95 95 96 - *Click**Create**togenerate thekey.90 +- TDE has now been enabled on the Managed instance 97 97 98 -===== **2. Enable TDE on the SQL Managed Instance** ===== 99 99 100 - ==========93 +Conclusion: All the databases have been encrypted by an asymmetric key. The key is the same for each database ( same encryption thumbprint). 101 101 102 - **-Navigate toYourManagedInstance:**95 +We are now able to backup databases from SSMS to Azure storage. 103 103 104 -* Go to your **SQL Managed Instance** (sqlmi-ebs-lab). 105 105 106 -**- Enable Transparent Data Encryption (TDE):** 107 107 108 -* Under **Security**, select **Transparent Data Encryption**. 109 109 110 -**- Configure TDE with a Customer-Managed Key (CMK):** 111 111 112 -* Select **Customer-managed key** as the encryption type. 113 -* Choose the key you created earlier from **Azure Key Vault** (mysqlmikey). 114 114 115 -**- Set the Key as Default TDE Protector:** 116 116 117 -* Make the key the **default TDE protector** for your instance. 118 118 119 -**- Save Configuration:** 120 120 121 -* Click **Save** to apply the changes. 122 122 123 -=== **Conclusion** === 124 124 125 -After following these steps, **TDE** has been successfully enabled on your **SQL Managed Instance** using an **asymmetric key** stored in **Azure Key Vault**. All databases within the instance are now encrypted using the same encryption key (identified by the same encryption thumbprint). You can now securely back up these encrypted databases from **SSMS** to **Azure Storage**. 126 126 127 -This process ensures that your data is protected both at rest and during backup, offering enhanced security for your managed databases in the cloud. 128 128 109 +1 CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'YourStrongPasswordHere!'; 110 +GO 129 129 112 +CREATE CERTIFICATE TDE_Certificate 113 +WITH SUBJECT = 'TDE Certificate'; 114 +GO 130 130 131 -=== **1. Backup Specific Databases Using SQL Server Agent Jobs** === 116 +2 USE master; 117 +GO 132 132 133 -This document describes the process of creating an automated **SQL Server Agent Job** to back up only the **DBA databases** in a SQL Server instance. The backups will occur **daily at 3:00 AM** and will be stored in an **Azure Storage Account** for secure and reliable cloud storage. 119 +SELECT 120 + cert.name AS Certificate_Name, 121 + cert.subject AS Certificate_Subject, 122 + cert.issuer_name AS Issuer_Name, 123 + cert.pvt_key_encryption_type AS Private_Key_Encryption_Type 124 +FROM 125 + sys.certificates cert 126 +WHERE 127 + cert.name LIKE 'TDE%'; 134 134 135 ----- 136 136 137 -==== **1. Create the Backup Script** ==== 130 +3 BACKUP CERTIFICATE TDE_Certificate 131 +TO FILE = https://zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D\TDE_Certificate.cer' 132 +WITH PRIVATE KEY ( 133 + FILE = https://zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D\TDE_PrivateKey.pvk', 134 + ENCRYPTION BY PASSWORD = 'AnotherStrongPasswordHere!' 135 +); 136 +GO 138 138 139 139 140 -====== **- Declaring Variables** ====== 139 +USE Normal; 140 +GO 141 141 142 -{{code language="sql"}} 143 -DECLARE @DatabaseName NVARCHAR(128) 144 -DECLARE @BackupContainerURL NVARCHAR(512) 145 -{{/code}} 142 +-- 6. Create a Database Encryption Key (DEK) and encrypt it with the TDE certificate 143 +CREATE DATABASE ENCRYPTION KEY 144 +WITH ALGORITHM = AES_256 145 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 146 +GO-- 146 146 147 -DECLARE @DatabaseName NVARCHAR(128) DECLARE @BackupContainerURL NVARCHAR(512) 148 +USE [dba] 149 +GO 148 148 149 -* **@DatabaseName**: A variable to hold the name of the database during each iteration of the loop. 150 -* **@BackupContainerURL**: A variable to store the URL of the Azure Blob Storage container where the database backups will be stored. 151 +CREATE DATABASE ENCRYPTION KEY 152 +WITH ALGORITHM = AES_256 153 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 154 +GO 151 151 152 ----- 153 153 154 -====== **2. Setting the Azure Blob Storage URL** ====== 157 +USE [dba1] 158 +GO 155 155 156 -{{code language="sql"}} 157 -SET @BackupContainerURL = 'https://<your_storage_account>.blob.core.windows.net/sql-backups/' 158 -{{/code}} 160 +CREATE DATABASE ENCRYPTION KEY 161 +WITH ALGORITHM = AES_256 162 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 163 +GO 159 159 160 160 161 ----- 166 +USE [dba2] 167 +GO 162 162 163 -====== **3. Declaring the Cursor** ====== 169 +CREATE DATABASE ENCRYPTION KEY 170 +WITH ALGORITHM = AES_256 171 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 172 +GO 164 164 165 165 166 -{{code language="sql"}} 167 -DECLARE db_cursor CURSOR FOR 168 -SELECT name 169 -FROM sys.databases 170 -WHERE name LIKE 'dba%' -- Only pick databases that start with 'dba' 171 -{{/code}} 175 +USE [dba3] 176 +GO 172 172 173 - * **CursorDeclaration**:174 - **Thecursordb_cursor is declared to loop through the list of databases in the sys.databases system view.175 - **The**WHEREname LIKE'dba%'** clauseensuresthat only databases with names starting with dba will be processed. For example, databases like dbaTest, dbaProd, etc., will be included in the loop.176 - ** **sys.databases**: A system catalog view that contains information about each database in the SQL Server instance.178 +CREATE DATABASE ENCRYPTION KEY 179 +WITH ALGORITHM = AES_256 180 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 181 +GO 177 177 178 ----- 183 +USE [xwiki] 184 +GO 179 179 180 -====== **4. Opening the Cursor** ====== 186 +CREATE DATABASE ENCRYPTION KEY 187 +WITH ALGORITHM = AES_256 188 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 189 +GO 181 181 182 -{{code language="sql"}} 183 -OPEN db_cursor 184 -FETCH NEXT FROM db_cursor INTO @DatabaseName 185 -{{/code}} 186 186 187 -OPEN db_cursor FETCH NEXT FROM db_cursor INTO @DatabaseName 192 +-- 7. Enable Transparent Data Encryption (TDE) on the database 193 +ALTER DATABASE dba 194 +SET ENCRYPTION ON; 195 +GO-- 188 188 189 -* **OPEN db_cursor**: This opens the cursor for reading the results. 190 -* **FETCH NEXT**: The FETCH NEXT statement retrieves the first database name that meets the LIKE 'dba%' condition and stores it in the @DatabaseName variable. This will be used in the next step where the backup procedure is executed. 191 191 192 ----- 198 +select name, database_id, state_desc 199 +from sys.databases 193 193 194 -====== **5. Looping Through Databases** ====== 195 195 196 - {{code language="sql"}}197 - --Loopthrougheachdatabaseandexecute the stored procedure198 - WHILE@@FETCH_STATUS=0199 - BEGIN200 - -- Printcurrentdatabasefor logging/debugging201 - PRINT 'Backing updatabase: ' + @DatabaseName202 +SELECT 203 + database_id, 204 + key_algorithm, 205 + key_length, 206 + encryption_state_desc 207 + encryptor_type 202 202 203 - -- Execute the DatabaseBackup stored procedure for each database 204 - EXECUTE dba.dbo.DatabaseBackup 205 - @Databases = @DatabaseName, -- Specify the current database 206 - @URL = @BackupContainerURL, -- Azure Blob Storage URL 207 - @BackupType = 'Full', -- Full backup type 208 - @CopyOnly = 'Y', -- Use copy-only backup (this doesn’t affect the transaction log chain) 209 - @Compress = 'Y', -- Enable compression 210 - @Verify = 'N'; -- Skip verification after backup 209 +FROM 210 + sys.dm_database_encryption_keys; 211 211 212 -{{/code}} 213 213 213 + Select * from sys.dm_database_encryption_keys 214 214 215 -* **WHILE @@FETCH_STATUS = 0**: The loop will continue as long as the FETCH command successfully retrieves a database name. @@FETCH_STATUS is a system function that returns 0 if the fetch operation is successful. 216 -* **PRINT**: This line prints the name of the database that is currently being backed up. It helps with logging or debugging purposes, as you can track which database is being processed at any given time. 217 -* ((( 218 -**EXECUTE dba.dbo.DatabaseBackup**: 219 219 220 -* This calls a stored procedure named dba.dbo.DatabaseBackup for each database. 221 -* The parameters passed to the stored procedure: 222 -** **@Databases = @DatabaseName**: Specifies which database to back up (the current database being processed). 223 -** **@URL = @BackupContainerURL**: Specifies the destination Azure Blob Storage URL. 224 -** **@BackupType = 'Full'**: Specifies the backup type, which is a **Full** backup (this means all data in the database is backed up). 225 -** **@CopyOnly = 'Y'**: Specifies that this is a **copy-only backup**. This ensures that the backup does not affect the transaction log chain and does not interfere with regular backups. 226 -** **@Compress = 'Y'**: Enables compression of the backup, reducing the size of the backup file. 227 -** **@Verify = 'N'**: Specifies that the backup verification step should be skipped. (Verification can be added if needed for additional safety.) 228 -))) 216 + BACKUP DATABASE [dba2] 217 +TO URL = '[[https:~~/~~/zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D'>>https://zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D']] 218 +With copy_only 219 +GO 229 229 230 ----- 231 231 232 -====== **6. Fetch the Next Database** ====== 222 +BACKUP DATABASE [dba2] 223 +TO URL = '[[https:~~/~~/zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D'>>https://zagpebslab.blob.core.windows.net/sql-backups?sp=racwl&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=eQKxB%2F0bg5cX71PmhUTlGHLCnIwSbe5CLOWVVkaDR1g%3D']], 224 +\\ COPY_ONLY, -- Ensures the backup does not affect the regular backup chain 225 + COMPRESSION, -- Optional: Compresses the backup to save storage space 226 + STATS = 10 -- Optional: Provides backup progress status 227 +GO-- 233 233 234 -{{code language="sql"}} 235 - -- Fetch the next database in the cursor 236 - FETCH NEXT FROM db_cursor INTO @DatabaseName 237 237 238 -{{/code}} 239 239 240 -~-~- Fetch the next database in the cursor FETCH NEXT FROM db_cursor INTO @DatabaseName 231 +-- Step 1: Drop the existing credential (if needed) 232 +DROP CREDENTIAL [https://zagpebslab.blob.core.windows.net/sql-backups]; 233 +GO-- 241 241 242 -* **FETCH NEXT**: After executing the backup for the current database, this statement retrieves the next database from the cursor and stores it in the @DatabaseName variable. The loop will continue until all matching databases have been processed. 235 +-- Step 2: Create a new credential with the SAS token 236 +CREATE CREDENTIAL [https://zagpebslab.blob.core.windows.net/sql-backups] 237 +WITH IDENTITY = 'SHARED ACCESS SIGNATURE', 238 +SECRET = 'sp=racwdli&st=2025-02-25T13:28:42Z&se=2026-02-25T21:28:42Z&spr=https&sv=2022-11-02&sr=c&sig=kBFwlj5S5eqBEE32LM1EFebBY0W94uEFiwOXo3R0yt4%3D'; 239 +GO-- 243 243 244 ----- 241 +-- Step 3: Perform the database backup with the provided parameters 242 +EXECUTE dba.dbo.DatabaseBackup 243 + @Databases = 'dba', -- Replace with your database name 244 + @URL = '[[https:~~/~~/zagpebslab.blob.core.windows.net/sql-backups'>>https://zagpebslab.blob.core.windows.net/sql-backups']], -- Azure Blob Storage URL 245 + @BackupType = 'Full', -- Full backup 246 + @CopyOnly = 'Y', -- Copy-only backup to avoid breaking backup chain 247 + @Compress = 'Y', -- Compress the backup 248 + @Verify = 'N'; -- No verification of backup 249 +GO-- 245 245 246 -====== **7. Closing and Deallocating the Cursor** ====== 247 247 248 -{{code language="sql"}} 249 --- Close and deallocate the cursor to clean up resources 250 -CLOSE db_cursor 251 -DEALLOCATE db_cursor 252 - 253 253 254 -{{/code}} 255 255 256 -* **CLOSE db_cursor**: This closes the cursor once the loop finishes processing all databases. 257 -* **DEALLOCATE db_cursor**: This deallocates the cursor, freeing up any resources used by the cursor. It’s a good practice to always deallocate cursors to avoid resource leaks. 258 258 259 -====== ====== 255 +select name, database_id, state_desc 256 +from sys.databases 260 260 261 -====== **8. Full Script** ====== 262 262 259 +SELECT 260 + database_id, 261 + key_algorithm, 262 + key_length, 263 + encryption_state_desc 264 + encryptor_type 263 263 264 -{{code language="sql"}} 265 -DECLARE @DatabaseName NVARCHAR(128) 266 -DECLARE @BackupContainerURL NVARCHAR(512) 266 +FROM 267 + select * from sys.dm_database_encryption_keys; 267 267 268 -SET @BackupContainerURL = 'https://zagpebslab.blob.core.windows.net/sql-backups' 269 269 270 -DECLARE db_cursor CURSOR FOR 271 -SELECT name 272 -FROM sys.databases 273 -WHERE name LIKE 'dba%' 270 + select name, is_encrypted from sys.databases 274 274 275 -OPEN db_cursor 276 -FETCH NEXT FROM db_cursor INTO @DatabaseName 277 277 278 -WHILE @@FETCH_STATUS = 0 279 -BEGIN 273 + SELECT 274 + cert.name AS Certificate_Name, 275 + cert.subject AS Certificate_Subject, 276 + cert.issuer_name AS Issuer_Name, 277 + cert.pvt_key_encryption_type AS Private_Key_Encryption_Type 278 +FROM 279 + sys.certificates cert 280 +WHERE 281 + cert.name LIKE 'TDE%'; 280 280 281 -PRINT 'Backing up database: ' + @DatabaseName 283 + ALTER DATABASE dba1 284 +SET ENCRYPTION off; 285 +GO 282 282 283 -EXECUTE dba.dbo.DatabaseBackup 284 - @Databases = @DatabaseName, 285 - @URL = @BackupContainerURL, 286 - @BackupType = 'Full', 287 - @CopyOnly = 'Y', 288 - @Compress = 'Y', 289 - @Verify = 'N'; 290 290 291 - FETCHNEXT FROMdb_cursor INTO @DatabaseName292 -EN D288 +Use dba1; 289 +DROP DATABASE ENCRYPTION KEY; 293 293 294 -CLOSE db_cursor 295 -DEALLOCATE db_cursor 296 296 292 +USE [dba1] 293 +GO 294 + 295 +CREATE DATABASE ENCRYPTION KEY 296 +WITH ALGORITHM = AES_256 297 +ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate; 298 +GO 299 + 300 + 301 + 302 +ALTER DATABASE dba1 303 +SET ENCRYPTION ON 304 + 305 + 306 + 307 + 308 + 309 + 310 + 311 + 312 + 313 + 314 + 315 + 316 + 317 + 318 + 319 + 320 + 321 + 322 + 323 + 324 +{{code language="sql"}} 325 +USE master; 326 +GO 327 +CREATE MASTER KEY ENCRYPTION BY PASSWORD = '******'; 328 +GO 329 + 330 +CREATE CERTIFICATE EBSphere_TDE_SQL2019_Cert WITH SUBJECT = 'Database_Encryption'; 331 +GO 332 + 333 +BACKUP CERTIFICATE EBSphere_TDE_SQL2019_Cert TO FILE = 'D:\temp\EBSphere_TDE_SQL2019_Cert' 334 +WITH PRIVATE KEY (file = 'D:\temp\EBSphere_TDE_SQL2019_Cert_Key.pvk', 335 +ENCRYPTION BY PASSWORD='*****') 336 + 337 +USE Everest_TDE_Master; 338 +GO 339 +CREATE DATABASE ENCRYPTION KEY 340 +WITH ALGORITHM = AES_256 341 +ENCRYPTION BY SERVER CERTIFICATE EBSphere_TDE_SQL2019_Cert; 342 +GO 343 +ALTER DATABASE Everest_TDE_Master 344 +SET ENCRYPTION ON; 345 +GO 346 + 347 +USE Everest_TDE_Master_Documents; 348 +GO 349 +CREATE DATABASE ENCRYPTION KEY 350 +WITH ALGORITHM = AES_256 351 +ENCRYPTION BY SERVER CERTIFICATE EBSphere_TDE_SQL2019_Cert; 352 +GO 353 +ALTER DATABASE Everest_TDE_Master_Documents 354 +SET ENCRYPTION ON; 355 +GO 297 297 {{/code}} 298 298 299 299 300 300 301 301 302 -=== === 303 303 304 304 305 305 ... ... @@ -309,9 +309,40 @@ 309 309 310 310 311 311 370 +{{code language="sql"}} 371 +USE master; 372 +GO 373 +CREATE MASTER KEY ENCRYPTION BY PASSWORD = '******'; 374 +GO 312 312 376 +CREATE CERTIFICATE EBSphere_TDE_SQL2019_Cert WITH SUBJECT = 'Database_Encryption'; 377 +GO 313 313 379 +BACKUP CERTIFICATE EBSphere_TDE_SQL2019_Cert TO FILE = 'D:\temp\EBSphere_TDE_SQL2019_Cert' 380 +WITH PRIVATE KEY (file = 'D:\temp\EBSphere_TDE_SQL2019_Cert_Key.pvk', 381 +ENCRYPTION BY PASSWORD='*****') 314 314 383 +USE Everest_TDE_Master; 384 +GO 385 +CREATE DATABASE ENCRYPTION KEY 386 +WITH ALGORITHM = AES_256 387 +ENCRYPTION BY SERVER CERTIFICATE EBSphere_TDE_SQL2019_Cert; 388 +GO 389 +ALTER DATABASE Everest_TDE_Master 390 +SET ENCRYPTION ON; 391 +GO 315 315 393 +USE Everest_TDE_Master_Documents; 394 +GO 395 +CREATE DATABASE ENCRYPTION KEY 396 +WITH ALGORITHM = AES_256 397 +ENCRYPTION BY SERVER CERTIFICATE EBSphere_TDE_SQL2019_Cert; 398 +GO 399 +ALTER DATABASE Everest_TDE_Master_Documents 400 +SET ENCRYPTION ON; 401 +GO 402 +{{/code}} 316 316 404 + 405 + 317 317
- image-20250305152543-1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.rudim - Size
-
... ... @@ -1,1 +1,0 @@ 1 -19.6 KB - Content