Solved

How to schedule backup of MS SQL 2012 Database?

Posted on 2016-07-18
5
45 Views
Last Modified: 2016-07-23
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
Comment
Question by:MichaelBalack
5 Comments
 
LVL 6

Accepted Solution

by:
Manju earned 500 total points
ID: 41717197
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
 
LVL 8

Expert Comment

by:Jose Torres
ID: 41717329
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
 
LVL 1

Author Comment

by:MichaelBalack
ID: 41717371
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
 
LVL 26

Expert Comment

by:Zberteoc
ID: 41717388
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
 
LVL 1

Author Closing Comment

by:MichaelBalack
ID: 41725599
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now