0

I have on my azure portal 2 sql databases, which for demonstration purpose I call them database one and database-two

Using python ODBC Driver 17, I am able to connect to database one and create a simple table. So far no big issues.

Where I am facing a problem, is when I try to make a backup of database-one I am getting this error:

pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for sql Server][SQL Server]Statment 'BACKUP DATABASE' is not supported in this version of SQL Server. (40510) (SQLExecDirectW)"

the line of code I am using to achieve this is as follow:

cursor.execute("BACKUP DATABASE [database-one] TO DISK = N'./backup.bak'")

Is there any solution how I can run the backup from pyodbc?

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
Nayden Van
  • 1,133
  • 1
  • 23
  • 70

1 Answers1

2

Azure Sql Not support to generate '.bak' format backup file. Azure Sql Not support to take back up of Azure SQL Database using Backup database command.

If you want to achieve the backup of Azure sql

you have to import the BACPAC File to a local SQL Server which supports importing BACPAC File. After a new User Database will be created. Then you could generate a '.bak' format file from the local SQL Server. Please Refer: How to create BAK file from azure sql db

For more info: https://learn.microsoft.com/en-us/azure/azure-sql/database/database-import?tabs=azure-powershell

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15