Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take backup of azure SQL-Managed Instance backup to azure blob

I am having a SQL-Managed Instance database now I wanted to take backup in .bak format to blob storage. The current Command I am using is

WITH IDENTITY = 'SHARED ACCESS SIGNATURE'
, SECRET = 'Pasted my sas token generated from azure portal blob storage'
go

BACKUP DATABASE [DB_Name]
TO URL = 'blob url/cointainer name/testing.bak'with checksum;

But by this I am getting a error: "BACKUP DATABASE failed. SQL Database Managed Instance supports only COPY_ONLY full database backups which are initiated by user."

I have also tried to give "COPY_ONLY" instead of checksum but then again I am facing a error: "Msg 41922, Level 16, State 1, Line 6 The backup operation for a database with service-managed transparent data encryption is not supported on SQL Database Managed Instance. Msg 3013, Level 16, State 1, Line 6 BACKUP DATABASE is terminating abnormally. "

Note: I have a database of approx size 800GB

like image 994
Gaurav Modi Avatar asked Sep 05 '25 17:09

Gaurav Modi


2 Answers

To prevent the original error message and you are comfortable with the increased security risks you can remove encryption:

Alter database [database_name] set encryption Off

use [database_name]

DROP DATABASE ENCRYPTION KEY

like image 188
Alex Ayscough Avatar answered Sep 07 '25 06:09

Alex Ayscough


Error is related to service managed TDE encryption since all database by default encrypted and service managed TDE does not allow to take copy_only backups. You need to either disable service managed TDE or Enable TDE with customer managed keys to take backups. Since your database size is 800 GB and if BackupSize > 200 GB then split your backups to multiple files. This is a limitation with blockblob.

like image 20
Shashikant Shakya Avatar answered Sep 07 '25 08:09

Shashikant Shakya