How to setup weekly auto backup in SQL Server 2012?

我只是一个虾纸丫 提交于 2019-12-08 18:33:22

问题


Please advice how can i setup automated database backup in my 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.


回答1:


In Microsoft SQL Server Management Studio, open the Object Explorer and then:

  1. Right-clic on Management > Maintenance Plans
  2. Clic on New Maintenance Plan...
  3. Give a name to your plan
  4. Create as many subplans as you need for your strategy
  5. Select a subplan and drag'n'drop the appropriate tasks from the Toolbox panel
  6. To backup a database, the appropriate task is 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

Hope this will help you




回答2:


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 Backup at 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.




回答3:


  1. Go to MS SQL Server Management studio→SQL Server Agent→New Job

  2. Under General tab enter Backup name

  3. Under Steps tab:

    1. Type Step name
    2. Select database you want to backup
    3. 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;
    
  4. In Schedules→New, go to new schedule and set date times as required




回答4:


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.




回答5:


Check this opensource backup windows service MFSQLBackupService, it did a great job for me.



来源:https://stackoverflow.com/questions/25860914/how-to-setup-weekly-auto-backup-in-sql-server-2012

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