Pages

Mar 5, 2018

Database Backups and Purge History using SQL Server Maintenance Plan

In the object explorer expand Management and right click on  Maintenance Plan and select Maintenance Plan Wizard


As you can see in the starting page, this wizard helps to automate all mentioned tasks.


Name your maintenance plan meaningfully.




Run As shows the service account this plan uses to execute.
Leave default schedule if you want to run all tasks on single schedule or check other option if you run them differently.
In addition, you can schedule it here by click on change button. We can also create a schedule one SQL job is created.


Select your task in this window and click next. I am checking full backup and cleanup tasks





You will see the task order and task brief information in this step.



Select the databases you want to backup, look at the options you have. You can select all user or system databases or all databases by selecting any one of first three options or manually select the databases by checking These Databases option.
You can also check the bottom button to avoid backing up databases, which are offline.



 Click Destination tab to give backup files and locations details.
Checking create a sub-directory for each database option will create separate folder for each DB.
If you want to take backup into more than one file, which is stripped backup check the first radio, button and add files. Choose the option Append or Overwrite depends upon your priority.
File extension by default for full backup is bak please leave it as is.


Here in this next window you will define the cleanup information. Select the options you want to keep your backup files. You can delete the files by age, file name or by extension of the file. 



Next is the report location of the execution details of these tasks. This helps to troubleshoot the errors.


Verify the configuration summary before you finish it.




Maintenance plan was created.



Check this job in SQL agent jobs.



Also, find it under Maintenance Plan in object explorer.



Double Click or right click and select Modify to open



I have tried few scripts to purge the backups but found few issues, Maintenance plan cleanup tasks works perfectly to purge the history. Give a try. 



No comments: