SQL backup job script windows schedule task

大憨熊 提交于 2020-01-17 02:20:07

问题


I knew about the possibility to get backup db using SQL server agent, but I was curious to know if we can have a backup script (like batch file) that just runs in windows and gets automatic backup according to the schedule that we define?

I think for the next part we can use windows task schedule (or crontab) for run the backup script job routinely, but the most important thing is to know: is it possible to login via SQL and backup the DB just using a batch scrip file (that there not be any need for SQL management studio completely and work completely independent)?
If the answer is yes, please let me know that I have it, too.

Maybe it seems to be a silly question, but I am not so experienced about that here.


回答1:


Yes you can!.

If you have SQLServer Express version you can't use SQLAgent, so the only way is outside of the SQLServer, like a .bat file. In this link you have an example script. .Bat Script

now you can use schedule task to schedule the backup.

If you can use SQL Agent, you could create a Mainteinance Plan for a Full Backup and next create a Job in SQL Agent to run it. In this link is you can find some examples, with script and mainteinance Plan and Jobs: With SQLAgent

hope this help!




回答2:


Assuming it's not Express, you create a backup job, which you can do in SQL Server Management Studio, and then schedule that backup job: https://docs.microsoft.com/en-us/sql/ssms/agent/schedule-a-job?view=sql-server-2017#SSMS and https://solutioncenter.apexsql.com/how-to-create-a-sql-server-scheduled-backup/ or https://www.youtube.com/watch?v=fdKePm7ImkM

Also maybe buy the SQL Server DBA exam guide and work through it, they go over it in fine detail. Hope that helps.



来源:https://stackoverflow.com/questions/41367424/sql-backup-job-script-windows-schedule-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!