如何在 SQL Server 2012 中设置每周自动备份?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25860914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setup weekly auto backup in SQL Server 2012?
提问by Shafraz Khahir
Please advice how can i setup automated database backup in my SQL Server 2012.
请建议我如何在我的 SQL Server 2012 中设置自动数据库备份。
I need to take all databases (currently it contains only 3 ) in SQL server an automated weekly backup which runs on Every Friday at 0100 h (1 AM). These back up files (*.bak) should be placed in E:\Backups folder.
我需要将 SQL 服务器中的所有数据库(目前它只包含 3 个)作为每周自动备份,该备份在每个星期五 0100 点(凌晨 1 点)运行。这些备份文件 (*.bak) 应放在 E:\Backups 文件夹中。
回答by Jo?l Salamin
In Microsoft SQL Server Management Studio
, open the Object Explorer
and then:
在 中Microsoft SQL Server Management Studio
,打开Object Explorer
,然后:
- Right-clic on
Management > Maintenance Plans
- Clic on
New Maintenance Plan...
- Give a name to your plan
- Create as many subplans as you need for your strategy
- Select a subplan and drag'n'drop the appropriate tasks from the
Toolbox
panel - To backup a database, the appropriate task is
Back Up Database Task
- 右键单击
Management > Maintenance Plans
- 点击
New Maintenance Plan...
- 为您的计划命名
- 根据您的战略需要创建尽可能多的子计划
- 选择一个子计划并从
Toolbox
面板中拖放相应的任务 - 要备份数据库,适当的任务是
Back Up Database Task
For the configuration of the backup schedule, you just need to follow the wizard and define what you want. If you need more information, i suggest you to go on the official website of Microsoft: Create a Full Database Backup
对于备份计划的配置,您只需要按照向导并定义您想要的内容。如果您需要更多信息,我建议您访问 Microsoft 的官方网站: 创建完整数据库备份
Hope this will help you
希望能帮到你
回答by LeonG
You can either create a SQL Server agent job or maintenance plan in ssms as mentioned, or use a 3rd party application. I use ApexSQL Backupat the moment, as it offers in depth schedule for any created job. You can specify if you want to create daily, weekly or monthly schedule. Besides, you can always pause, or delete these schedules if you don't want to use them for some reason.
您可以如上所述在 ssms 中创建 SQL Server 代理作业或维护计划,也可以使用第 3 方应用程序。我目前使用ApexSQL Backup,因为它为任何创建的作业提供了深入的计划。您可以指定是否要创建每日、每周或每月计划。此外,如果您出于某种原因不想使用它们,您可以随时暂停或删除这些计划。
回答by peter bence
Check this opensource backup windows service MFSQLBackupService, it did a great job for me.
检查这个开源备份 Windows 服务MFSQLBackupService,它对我来说做得很好。
回答by Gayan Chinthaka Dharmarathna
Go to MS SQL Server Management studio→SQL Server Agent→New Job
Under General tab enter Backup name
Under Steps tab:
- Type Step name
- Select database you want to backup
- Enter backup query
Note: Sample backup query here with backup name date and time (e.g.
TestBackup_Apr 4 2017 6,00PM.bak
)DECLARE @MyFileName nvarchar(max) SELECT @MyFileName = (SELECT N'E:\TestbackupFolder\TestBackup_' +replace(rtrim(convert(char,getdate())), ':',',')+ '.bak') BACKUP DATABASE [yourdatabasename] TO DISK=@MyFileName WITH INIT;
In Schedules→New, go to new schedule and set date times as required
转到 MS SQL Server 管理工作室→SQL Server 代理→新建作业
在常规选项卡下输入备份名称
在步骤选项卡下:
- 输入步骤名称
- 选择要备份的数据库
- 输入备份查询
注意:此处的示例备份查询带有备份名称日期和时间(例如
TestBackup_Apr 4 2017 6,00PM.bak
)DECLARE @MyFileName nvarchar(max) SELECT @MyFileName = (SELECT N'E:\TestbackupFolder\TestBackup_' +replace(rtrim(convert(char,getdate())), ':',',')+ '.bak') BACKUP DATABASE [yourdatabasename] TO DISK=@MyFileName WITH INIT;
在时间表→新建,转到新时间表并根据需要设置日期时间
回答by Mary17
I can advice you to try the software Cloudberry as a backup agent to backup the data you wish. It sets the automated backup in the way you want to do it and place the backups where you want.
我可以建议您尝试使用 Cloudberry 软件作为备份代理来备份您想要的数据。它以您想要的方式设置自动备份,并将备份放置在您想要的位置。