terça-feira, janeiro 05, 2021

SQL Backup and Restore ( Encryption Database)

 Backup:

To encrypt a backup you need certificate or an asymmetric key.

Create a Master Key:

USE master

GO

CREATE MASTER KEY ENCRYPTION BY PASSWORD = '(Password123)'

Create a certificate

CREATE CERTIFICATE BackupCertificate

WITH SUBJECT ='Backup Encryption Certificate'

Create a Backup:

 

 Backup Certificate:

You must save your certificate and private key, without that you will not able to restore the backups:

BACKUP CERTIFICATE BackupCertificate

   TO FILE = 'D:\cert\BackupCertificate.cer' 

   WITH PRIVATE KEY(

      FILE='D:\cert\KeyBackupCertificate.ppk',

      ENCRYPTION BY PASSWORD ='(Password123)'

   )

 Restore:

If you try to restore the database in another server without the certificate you will get this message:

 

 You need to create the master key before restore ( Destination Server):

CREATE MASTER KEY ENCRYPTION BY PASSWORD = '(Password123)'

Now, you need to create the certificate using the existing certificate and password, in my example is in the cert folder: 

 Create a certificate on the destination server

CREATE CERTIFICATE BackupCertificate

   FROM FILE = 'D:\cert\BackupCertificate.cer'

   WITH PRIVATE KEY(

      FILE ='D:\cert\KeyBackupCertificate.ppk',

      DECRYPTION BY PASSWORD='(Password123)'

   )

Now, I was able to restore:

 

terça-feira, dezembro 15, 2020

Reverse DNS PublicIp - Azure

This is the step to configure a reverse DNS for an IP address:

DNS Zone:

maykonrds.online

My public IP:

 

The fisrt step is create a DNS name label for the public IP:

 

DNS name label:

maykonrds.southcentralus.cloudapp.azure.com 

In your DNS zone create a CNAME and point to maykonrds.southcentralus.cloudapp.azure.com ( You can use any hostname )

 

The final step is a PowerShell:

>$pip=Get-AzPublicIpAddress -Name adsrv2-vm-ip
>$pip.DnsSettings

>$pip.DnsSettings.ReverseFqdn="maykonrds.maykonrds.online"

>Set-AzPublicIpAddress -PublicIpAddress $pip

 Check the changes:

 

You can check your DNS zone using the ping command:

 

Another Option:

Network Tools: DNS,IP,Email (mxtoolbox.com)