如何自动备份SQL数据库为脚本文件(.sql文件)

huangapple go评论73阅读模式
英文:

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

问题

我可以使用SSMS保存我的Azure SQL数据库为脚本,按照这个指南操作:
https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/common-import-and-export-sql-database-to-sql-script-via-sql-management-studio

如何使这个脚本导出过程自动化?我想每天早上运行它,而不必手动操作。

我找到了一些解决方案,可以实现自动数据库备份,但目前还没有找到能将备份保存为.sql文件的方法。

我更喜欢.sql文件而不是.bak文件,因为我希望在可能恢复备份之前能够阅读和编辑它(这是一个小型数据库)。

英文:

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).

答案1

得分: 2

如果您正在使用Azure SQL,您可能已经意识到数据库会自动备份。然而,为了回答您的具体问题,您可以编写一个PowerShell脚本,然后让Azure自动化定期执行此脚本。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月22日 05:20:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527217.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定