Using a maintenance plan for SQL Server 2008 enables you to automatically back up the database and automatically remove the functionality of outdated backups.
First, the environment
Os:microsoft Windows Server 2003 R2
Soft:microsoft SQL Server 2008
Backing up the database path C:\sql_bak
Second, the configuration
Login MicrosoftSQL Server Management studioà management à maintenance plan right-click: Create a new maintenance plan, such as:
Enter the maintenance plan name, click the OK button, and the right-hand interface goes to the Plan design window, from the left-hand toolbox (View à Toolbox: open Toolbox) Drag a Backup database task to the design window, such as:
Double-click the Backup Database task session box to set up the database information that you want to back up, such as:
When set, click the OK button, go back to the design window, click the button, and pop up the job Schedule Properties window, such as:
Set the job Schedule backup time, (for the convenience of testing, here set the backup execution interval of 10 minutes) set, click the "OK" button, back to the design window. Drag a purge maintenance task from the left-hand toolbox to the design window, such as:
Double-click the Purge Maintenance task session box to pop up the Cleanup Maintenance Task window, such as:
Select the backup database file path, the extension fills Bak, set the delete file condition, and when finished, click the OK button to return to the design window. Save the maintenance plan, and the Left Object Explorer window will see the maintenance plans and jobs that you just completed, such as:
Select the job that corresponds to the new maintenance plan that you just created, right-click the job start step, such as:
The status bar is displayed successfully, and the maintenance plan is set successfully by clicking the Close button.
Third, testing
Go to the Backup folder C:\sql_bak View the backup situation, such as:
Modify server time for 2014-4-11 13:00 Review the backup situation again, such as:
A backup of 1 hours ago was found to have been deleted.
Iv. Frequently Asked Questions
1. After the maintenance plan configuration is complete, the backup succeeds, and the log shows that the cleanup maintenance task also succeeds, but it does not actually delete the outdated backup
Solution: Open SQL Server Configuration Management tool Àsql Server service,
The account used by the SQL Server service, SQL Server Agent service, and the Database backup folder (C:\sql_bak) should have the delete permission, preferably using the same account.
2, configure the deletion of the account permissions
Right-click the "Security" tab to locate the user you are using, click the "Advanced" button, and tick delete permissions, such as:
After the permission configuration is complete, restart the service, and the problem is resolved.
Using the SQL Server 2008 Maintenance Plan (plot)