33
MS SQL Server Help Topics Maintenance Plan Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 1 MS SQL Server Maintenance Plan The purpose of this guide is to walk you through setting up a maintenance plan for your TFW database. When you are done you will have set up an automatic database and transaction log backup and a cleanup plan. Requirements Microsoft SQL Server 2005 with Service Pack 3 2005.90.4035 or higher, Database compatibility Level = SQL Server 2000 (80) Microsoft SQL Server 2008 RTM 2007.100.1600.0, Database compatibility Level = SQL Server 2000 (80) We have not tested this yet, however the process appears to be the same. Set up Maintenance Plan 1. Open Microsoft SQL Server Management Studio. Drill down to Management > Maintenance Plans. Right click on Maintenance Plans and select Maintenance Plan Wizard.

MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

Embed Size (px)

Citation preview

Page 1: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 1

MS SQL Server Maintenance Plan

The purpose of this guide is to walk you through setting up a maintenance plan for your TFW database. When you are done you will have set up an automatic database and transaction log backup and a cleanup plan.

Requirements Microsoft SQL Server 2005 with Service Pack 3 2005.90.4035 or higher, Database compatibility Level = SQL Server 2000 (80)

Microsoft SQL Server 2008 RTM 2007.100.1600.0, Database compatibility Level = SQL Server 2000 (80) We have not tested this yet, however the process appears to be the same.

Set up Maintenance Plan 1. Open Microsoft SQL Server Management Studio. Drill down to Management > Maintenance Plans.

Right click on Maintenance Plans and select Maintenance Plan Wizard.

Page 2: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 2

2. You will now see the SQL Server Maintenance Plan Wizard screen. Click Next.

3. Now the Select Plan Properties screen is visible. Give the plan a Name and if you want a

Description. Select Separate schedules for each task. Click Next.

Page 3: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 3

4. Now the Select Maintenance Tasks screen is displayed. Check the following boxes Check

Database Integrity, Reorganize Index, Rebuild Index, Back Up Database (Full), Back Up Database (Transaction Log) and Maintenance Cleanup Task. Then click Next.

Page 4: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 4

Page 5: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 5

5. Now you will come to the Select Maintenance Task Order Screen. The default order is OK click Next.

6. On the Define Database Check Integrity Task screen select the Databases pull down menu and

then select the database(s) to be backed up. If you have a test or demo database it might be a good idea to include it as well. Click OK.

Page 6: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 6

Page 7: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 7

7. Now you are back on the Define Database Check Integrity Task screen. Now click the Change button.

8. The Job Schedule Properties screen will appear. In the Frequency Section change Occurs to Daily.

In the Daily Frequency section check Occurs every and fill in 8 hours. Starting at 1:00 AM and Ending at 11:59:59 PM. Click OK. You will be back at the Define Database Check Integrity Task screen, click Next.

Page 8: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 8

Page 9: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 9

9. You are now at the Define Reorganize Index Task screen. Select the database(s) from the Databases pull down menu. After you have selected the database(s) click OK.

10. You will be back at the Define Reorganize Index Task screen. Under the Object pull down menu

make sure Tables and views is selected. Compact large objects should be checked. Now click the Change button.

11. Now you will see the Job Schedule Properties window. Under Daily Frequency change the Occurs once at to 1:15 AM. Click OK. You will be back at the Define Reorganize Index Task screen. Click Next.

Page 10: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 10

Page 11: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 11

12. Now you see the Define Rebuild Index Task screen. Select the database(s) from the Databases pull down menu. After you have selected the database(s) click OK.

13. You will be back at the Define Rebuild Index Task screen. Under Object make sure Tables and

views is selected. In the Free Space Options section check Change free space per page percentage to: 10%. Click Change.

14. Now you will see the Job Schedule Properties screen. Under the Daily frequency section set Occurs once at: to 1:30 AM. Click OK. You will be back at the Define Rebuild Index Task screen. Click Next.

Page 12: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 12

Page 13: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 13

15. Now you are at the Define Back Up Database (Full) Task window. Select the database(s) from the Databases pull down menu. After you have selected the database(s) click OK.

16. You are now back at the Define Back Up Database (Full) Task window. Under Backup component

select Database. Check Backup set will expire and then check After fill in 7 days. Under Back up to select Disk. Make sure that Create a backup file for every database is checked and then under Folder put in the path where you would like the backup file created. By default the path will be C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup. The Backup file extension: should be bak. Check the Verify backup integrity box. Then click Change.

Page 14: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 14

17. You are now at the Job Schedule Properties screen. Under Daily Frequency Occurs once at:

should be set to 2:00 AM. Click OK. You will be back at the Define Back Up Database (Full) Task screen. Click Next.

Page 15: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 15

18. Now you are at the Define Back Up Database (Transaction Log) Task window. Select the

database(s) from the Databases pull down menu. After you have selected the database(s) click OK.

Page 16: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 16

19. You are now back at the Define Back Up Database (Transaction Log) Task window. Check the

Backup set will expire: to 3 days and then check After fill in 3 days. Next check Back up to: Disk. Make sure that Create a backup file for every database is checked and then under Folder put in the path where you would like the backup file created. By default the path will be C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup. The Backup file extension: should be trn. Then click Change.

Page 17: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 17

20. You are now at the Job Schedule Properties screen. Go to Frequency section and change

Occurs: to Daily. Under Daily Frequency check Occurs every: should be set to 4 hours. Starting at: 12:00:00 AM Ending at: 11:59:59 PM. Click OK. You will be back at the Define Back Up Database (Transaction Log) Task screen. Click Next.

Page 18: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 18

21. You are now at the Define Maintenance Cleanup Task screen. Under Delete files of the following

type: select Backup files. Then check Search folder and delete files based on an extension. Under Folder put in the file path to where you are backup files are located. In the File extension: type bak. Under File age: check the Delete files based on the age of the file at task run time box. After Delete files older than the following: select 1 and Week(s). Click Change.

Page 19: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 19

22. You are now on the Job Schedule Properties screen. Under Daily frequency Occurs once at:

should read 3:00:00 AM. Click OK. Click OK. You will be back at the Define Maintenance Cleanup Task screen. Click Next.

Page 20: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 20

23. You are now at the Select Report Options screen. Creating a log is optional. If you do not want a log

of the job execution uncheck the Write a report to a text file box. If you do want the log check the appropriate box and fill in the file path or E-mail recipient. Click Next.

Page 21: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 21

Page 22: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 22

24. You are now on the Complete the Wizard screen. Review the information if something is wrong click Back and correct the wrong information. If everything is correct click Finish.

25. You will now see the Maintenance Plan Wizard Progress screen. It will write the plan and when

finished you will see the success window. Click Close to finish this portion of the Maintenance Plan.

Page 23: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 23

Page 24: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 24

Transaction Log Cleanup The Maintenance Plan only allows for 1 cleanup task, we used that cleanup task to remove the old backup files (bak). Now we have to set up a Maintenance plan to remove the old Transaction Log files (trn).

Creating the Transaction Log Backup Cleanup 1. Open Microsoft SQL Server Management Studio. Drill down to Management > Maintenance Plans.

Right click on Maintenance Plans and select Maintenance Plan Wizard.

Page 25: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 25

2. You will now see the SQL Server Maintenance Plan Wizard screen. Click Next.

3. Now the Select Plan Properties screen is visible. Give the plan a Name and if you want a

Description. You may leave Single schedule for entire plan or no schedule checked. Click Change.

Page 26: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 26

4. Now you are on the Job Schedule Properties screen. Under the Daily frequency section check

Occurs once at: and type in 3:15:00 AM. Click OK. When back on the Select Plan Properties screen click Next.

Page 27: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 27

5. You are now on the Select Maintenance Tasks Screen. Check the box in front of Maintenance

Cleanup Task. Click Next.

Page 28: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 28

Page 29: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 29

6. You are now on the Select Maintenance Task Order screen. Click Next.

7. You are now at the Define Maintenance Cleanup Task screen. Under Delete files of the following

type: select Backup files. Then check Search folder and delete files based on an extension. Under Folder put in the file path to where you are backup files are located. In the File extension: type trn. Under File age: check the Delete files based on the age of the file at task run time box. After Delete files older than the following: select 1 and Week(s). Click Next.

Page 30: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 30

8. You are now at the Select Report Options screen. Creating a log is optional. If you do not want a log

of the job execution uncheck the Write a report to a text file box. If you do want the log check the appropriate box and fill in the file path or E-mail recipient. Click Next.

Page 31: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 31

Page 32: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 32

9. You are now on the Complete the Wizard screen. Review the information if something is wrong click Back and correct the wrong information. If everything is correct click Finish.

10. You will now see the Maintenance Plan Wizard Progress screen. It will write the plan and when

finished you will see the success window. Click Close. The Maintenance Plan is now complete.

Page 33: MS SQL Server - TMW Systemstmws.tmwsystems.com/learningcenter/TMNT/docs_SQL/MS SQL Server... · MS SQL Server Maintenance Plan ... Microsoft SQL Server 2005. with Service Pack 3 2005.90.4035

MS SQL Server Help Topics Maintenance Plan

Copyright © 2009 by TMW Systems, Inc. 9/2009 A Business Confidential Document 33