[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 120
  • Last Modified:

How to schedule backup of MS SQL 2012 Database?

This is using MS SQL Server 2012 R2 on MS Windows Server 2012 R2 server. The objective is to have a daily schedule to backing up one database into E:\DBBackups folder. I am thinking of making use of MS Task scheduler to do this scheduling backup jobs. BTW, how to write a script/batch file in order to backing up this database into E:\DBBackups folder, so as a subfolder will be created based on the date of the day? for example, for date - 15th July, a subfolder, such as 140716 was created with the latest DB backing up into it?
Please show step by step.

Appreciate for any help.
0
MichaelBalack
Asked:
MichaelBalack
1 Solution
 
ManjuIT - Project ManagerCommented:
In Microsoft SQL Server Management Studio, open the Object Explorer and then:

Right-click 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
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

https://msdn.microsoft.com/en-us/library/ms187510.aspx
0
 
Jose TorresCommented:
Is there a reason why you need the backup directory to have the date.  The maintenance plan can be configured to create a folder for each database being backed up and it will append a date time stamp to the file name.

Additionally to creating the Backup database task you should also create a "Maintenance Cleanup Task" to delete backup files, otherwise they will pile up in the folder.

On a side note you should be backing up all your databases (system db's included), specially if this is a production system.  Even if it's a test system you want to backup at some intervals to allow you to recover if something got messed up.
0
 
MichaelBalackAuthor Commented:
Hi Jose,

Without a subfolder is ok. So long as there is a way to identify the backup files. Btw, can you show example on how to use this maintenance plan?

Cleanup also important as we just want keep the latest 10 copies.

thanks,
0
 
ZberteocCommented:
The best and easies way to do it is to use Ola Hallegren maintenance solution. Beside backup i recommend you the Index Optimisation and the Integrity Check as well, even though they are separate of one another:

https://ola.hallengren.com/

For the backup use the backup stored procedure and the job that it automatically creates for you if you use the master script(the one that isntalles the whole solution, not just the backup). After you ran it you just go and set a schedule to the USER_DATABASES Backuo Job. You will have to edit the backup location in the Job to the one you want to use.
0
 
MichaelBalackAuthor Commented:
Thanks for expert - Manju, in suggesting using MS SQL Management studio maintenance plan. I using the 2 main tasks - maintenance cleanup, and full database backup, and they can fulfill my objective.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now