Open your SQL server Management Studio
Log into SQL Server Management Studio (SSMS) and connect to the database. Go to the Object Explorer window (located on the left) and make sure that your SQL Server Agent is running.
Open the folder named Management and find the Maintenance Plan folder. Then right-click on Maintenance Plan folder and select New Maintenance Plan. How to Backup SQL Database Automatically
Enter the name of the Maintenance Plan you are going to create. Press on the calendar icon on the top-right highlighted section on the job schedule screen. It will bring up the job schedule screen. In the opened window set up all necessary backup schedule.
Now choose from the left-side window, select the Backup Database Task to set up the backup process and drag the element onto the right window as shown in the picture.
Now you need double-click on the database task. In the opened window set up, the configuration related to the database backup.
Specify the databases you are going to backup. Also, you can pick the files to expire after specific period or on a specific date.
Now from the Object Explorer > SQL Server Agent > Jobs
under the SQL Agent jobs, we may find the job that created automatically according to the Maintenance Plan that we created.
And right-click on this job, and press Start job at Step, to test the maintenance plan that we created before,
Now let’s go to the backup file that we defined previously to check the backup,
SQL Server Express editions do not offer a way to schedule either jobs or maintenance plans because the SQL Server Agent component is not included in these editions. Therefore, you have to take in consideration a different approach to back up your databases when you use these editions.
Currently SQL Server Express users can back up their databases by using one of the following methods:
- Use SQL Server Management Studio Express. This is installed together with either SQL Server Express Advanced Service or SQL Server Express Toolkit.
- Use a Transact-SQL script that uses the BACKUP DATABASE family of commands.
Maintenance Plans are more suitable for less experienced DBAs because they provide an easy to use GUI, and do not require manually written maintenance scripts. The downside of Maintenance Plans is that the tasks that Maintenance Plans provide are basic and don’t leave space for customization.
A Maintenance Plan is also atomic and is therefore not able to run multiple tasks. Each type of maintenance task within a single Maintenance Plan can only be configured to run once within that Plan. For example, if a task that is made to delete older backup files it will only delete one file type at a time. Because of this multiple Maintenance Plans have to be created just to perform a single task, in some cases, and every Maintenance Plan has to have a corresponding SQL Server Agent job to be scheduled.
That is all, your backup plan is ready, and all your backups will be made according to the specified schedule. Now you know how to backup SQL database automatically.
No comments:
Post a Comment