Saturday, May 19, 2012

Scheduling automated backup using SQL server 2008

Are you backing up your SQL Server 2008 databases daily?  You should be, especially if you don't want to lose any of your precious data that you're storing.  It's incredibly easy to setup a maintenance plan in SQL Server 2008 to automatically back up one or more databases. To get started backing up your databases using SQL Server Management Studio follow the steps below.
  1. Users to schedule the backup to be taken on a particular interval
  2. Once scheduled backup task completion we can send alert message to DBA.
  3. Delete the backup copies after a certain period of time
Here's how to setup automatic daily backups for SQL Server 2008 databases:
Schedule the database backup
Step: 1
Login to Sql Management studio and connect to the required database. Now from the object explorer, make sure SQL server agent is running, if not start SQL server agent(Right click and press start) as shown below screen shot.
Step: 2
Expand the Management Node from the object explorer, and then select the maintenance plan node. To schedule maintenance plan, you need to have “SYSADMIN” database role. If you dont see the maintenance node, make sure you have the necessary permission. As shown in the below screen. 
Step: 3
Right click the maintenance plan and then select “New Maintenance Plan”.
Step: 4
Enter the maintenance plan name in the popup box (This can be any name that identifies your task for ). This will identify your backup plan and you should choose a relevant name that suits your plan.
Step: 5
Now you will be in the configuration page for the maintenance plan. . Note the marked area, these are the areas you need to use for setting up the maintenance plan. The marked area in the right top will be used to configure the time that the plan executes. Choose a time so that the database is least used. The bottom left pane shows the tasks that can be utilized to create an sql maintenance plan.
Step: 6
Click on the calendar item shown in the right side top. This will bring the job schedule properties popup window that configure the execution time/frequency of the tasks. Configure the data carefully so that it suits your requirement. Usually database backups are taken daily basis. Make sure you are selecting proper time so that your database is least used. Click "Ok"once you finish.
Step: 7
From the maintenance plan tasks pane in the left side, select the Backup Up Database Task, this will be used to take backups for the databases. Drag and drop backup database task to the right side(as shown in the Screen shot). 
Step: 8
Form the above screen shot you can find Backup Up Databse Task is showing a Cross symbol. It means that it is not yet configured. To configure double click on the Backup Up Database Task, it will open up a new window that allows you to configure the database configuration for the backup. Here you configure the databases that you need to backup for one or more databases, then specify a location for the backup, specify the extension for the backup files etc.
From the pop up modal window, by clicking on “Databases” dropdown, you will be able to select the required databases. Also configure the file location, extension for the backup file etc.


Step: 8 
Click Ok once finished. Now backup plan configuration is over. The backup files will be created on the scheduled time to the mentioned folder. The name of the file will be created by appending the date so that you can identify the back up for a particular date.
Since the backup files are created frequently,… 

it is a good practice that you delete backup files after a certain period of time. For this you need to execute clean up task  along with the Maintenance plan. You can configure the clean up task as follows.
From the left side pane, drag and drop "Maintenance Cleanup Task."
Step: 9
Double click on the dropped item inorder to edit the clean up properties. Here you need to specify the backup location, and file extension for the back up files and specify the age of the file. It is a good practice that you keep one month old data, and delete anything prior to one month.
Once you click ok, then save the maintenance plan. 
Step: 10
After doing all these you can find scheduled backup task under Maintenance plan in the object folder. You can either wait till the next execution time or execute it manually in order to check whether everything is working fine. To execute manually select the plan and right click on it and then select "Execute" option. Check in the destination folder whether it is working fine or not.

No comments:

Post a Comment