Backing up with SQL HyperBac encryption
Published 06 February 2015
First, consider the T-SQL command that you would normally use to back up the "AdventureWorks" database:
BACKUP DATABASE [AdventureWorks] TO DISK = 'D:\Backups\AdventureWorks_backup.bak'
To back up AdventureWorks with SQL HyperBac AES-256 encryption:
In the T-SQL statement, simply change the extension of the backup file to .hbe:
BACKUP DATABASE [AdventureWorks] TO DISK = 'D:\Backups\AdventureWorks_backup.hbe'
That's all you need to do. SQL HyperBac will automatically apply encryption to 'AdventureWorks_backup.hbe' when you run this T-SQL statement.
Whether you run the T-SQL statement from SQL Server Management Studio (either by explicitly typing the statement, or using the GUI options), using SQLCMD, or with any other tool, SQL HyperBac will automatically intercept the backup data, and encrypt it.
Note that if SQL HyperBac does not find a key file in the 'keys' folder (located at "C:\Program Files\Red Gate\HyperBac\keys" by default), it will generate a random key, and write this to a new key file.
Read Managing key files for encrypted backups for important information about managing and backing up key files.
Exporting data from AdventureWorks.Sales.customer with SQL HyperBac AES-256 encryption
You can apply SQL HyperBac encryption to the output of export operations (using 'bcp') in exactly the same way as for 'BACKUP DATABASE' commands.
Consider the bcp command that you would normally use to export data from the AdventureWorks.Sales.customer table (on a local instance named "PRODUCTION"):
bcp AdventureWorks.Sales.customer out D:\Backups\Export.dmp -Slocalhost\PRODUCTION -T -n -b1000
In the bcp command, simply change the extension of the export file to .hbe:
bcp AdventureWorks.Sales.customer out D:\Backups\Export.hbe -Slocalhost\PRODUCTION -T -n -b1000
SQL HyperBac will automatically encrypt the exported data as for the BACKUP DATABASE example above.