Solved

How to schedule backup of MS SQL 2012 Database?

Posted on 2016-07-18
5
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 27

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

739 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