Solved

How to schedule backup of MS SQL 2012 Database?

Posted on 2016-07-18
5
75 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OSQL to execute sql command 26 26
Row insertion failed. Array 5 48
SQL Syntax Grouping Sum question 7 27
Stored Procedure needs owner to execute 5 26
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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

808 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