Search code examples
azureazure-sql-databasessms

How to automatically backup a SQL Database as a script (.sql file)


I am able to save my Azure SQL database as a script using SSMS following this guide: https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/common-import-and-export-sql-database-to-sql-script-via-sql-management-studio

How can I make this script export an automatic process? I would like to run it every morning without having to do this manually.

I have found several solutions to make automatic database backups, but none so far that save the backup as a .sql file.

I would prefer a .sql file over a .bak file, as I would like it to be readable & editable before potentially restoring a backup (this is a small database).


Solution

  • If you are using Azure SQL you're probably aware that the database is automatically backed up. However, to answer your specific question you could write a PowerShell script and then have Azure Automation execute this on a regular basis.