zoukankan      html  css  js  c++  java
  • Create maintenance backup plan in SQL Server 2008 R2 using the wizard

    You will need to identify how you want your maintenance plan to be setup. In this example the maintenance plan will be setup with full backups, differentials, and transactions logs.

    Check SQL Server Agent Service

    Verify the SQL Server Agent service is running and set to automatic. The maintenance plans depend of the server in order to run. When configuring the service to ‘Automatic’ select the ‘Recovery’ tab, and set the failure to ‘Restart the Service’.

    Go to ‘Run’ and type in ‘services.msc’ and press enter.

    4214.1[1]_thumb[1]

    Then find the SQL Server Agent service in the list and double click.

    6431.2[1]_thumb[1]

    From there you want to configure the service for automatic startup. Then go ahead and start the service.

    5751.3[1]_thumb[1]

    Creating the Maintenance Plan

    Next, launch the SQL Management Studio.

    Once your logged in go to the ‘Maintenance Plans’ folder under ‘Management’. Right click on ‘Maintenance Plans’ and choose ‘Maintenance Plan Wizard.

    2605.4[1]_thumb[1]

    Click Next

    4760.5[1]_thumb[1]

    Select ‘Separate schedules for each task’ radio button and click next.

    3441.6[1]_thumb[4]

    Select backup Database Full, Differential, and Transaction Log check boxes and click next.

    8741.7[1]_thumb[1]

    Click Next

    6366.8[1]_thumb[1]

    Full Backup Settings

    This is where you setup the backup settings for the full backup task.
    1. Select the databases you want backed up. (All user databases).
    2. Choose when you want the backups to expire. In this case I chose (14 days). This will overwrite the oldest backup file for rotation.
    3. Choose your backup media. (Disk)
    4. Choose a location for you backups. (Default or to your liking)
    5. Verify the integrity of the backup.
    6. Click the configure button at the bottom right to configure the scheduling options for this task.

    3286.9[1]_thumb[1]

    1. Choose the Schedule type. (Recurring)
    2. Choose the frequency of the backup. In this example full backups are running on Monday, Wednesday, and Friday. (Alter this to fit your backup plan).
    3. Adjust the Daily frequency. (What time does your backup need to run)?
    4. Adjust the start and end date. In this example I left it at ‘No end date’.

    5153.10[1]_thumb[1]

    Click OK when you are finished. Go back to the maintenance plan wizard and click next.

    Differential Backup Settings

    Next we will configure the differential backup task.
    1. Select the databases you want backed up. (All user databases).
    2. Choose when you want the backups to expire. In this case I chose (14 days). This will overwrite the oldest backup file for rotation.
    3. Choose your backup media. (Disk)
    4. Choose a location for you backups. (Default or to your liking)
    5. Verify the integrity of the backup.
    6. Click the configure button at the bottom right to configure the scheduling options for this task.

    2642.11[1]_thumb[1]

    1. Choose the Schedule type. (Recurring)
    2. Choose the frequency of the backup. In this example differential backups are running on Tuesday, Thursday, Saturday, and Sunday. (Alter this to fit your backup plan).
    3. Adjust the Daily frequency. (What time does your backup need to run)?
    4. Adjust the start and end date. In this example I left it at ‘No end date’.

    0535.12[1]_thumb[1]

    Click OK when you are finished. Go back to the maintenance plan wizard and click next to configure the transaction log backup.

    Transaction Log Backup Settings

    Next, setup the transaction logs backup.
    1. Choose your databases. (All user databases)
    2. Do not check ‘back set will expire’. (We will setup a cleanup task next).
    3. Choose your backup media. (Disk)
    4. Choose a location for you backups. (Default or to your liking). ****Copy and paste the path to notepad. You will need to reference this in later steps. ********
    5. Verify the integrity of the backup.
    6. Click the configure button at the bottom right to configure the scheduling options for this task.

    8154.t13[1]_thumb[1]

    The transaction log backup intervals will need to be determined based on transaction logs growth. Therefore it may be necessary to run the transaction log backups in shorter intervals to prevent transaction logs from growing.
    1. Choose the Schedule type. (Recurring)
    2. Choose the frequency of the backup. In this example the transaction log backups are running daily.
    3. Adjust the Daily frequency. (I set mine to run every hour).
    4. Adjust the start and end date. In this example I left it at ‘No end date’.

    2870.t14[1]_thumb[1]

    Click OK when you are finished. Go back to the maintenance plan wizard and click next to finish the wizard.

    1362.t15[1]_thumb[1]

    0602.t16[1]_thumb[1]
    Click ‘Close’ to finish.
    7217.t17[1]_thumb[1]

    Now that you are back to the SQL Management Studio main screen you need to refresh the maintenance plan. Press F5 to refresh the new settings. You should see the new Maintenance Plan listed.

    1832.t18[1]_thumb[1]

    Transaction Log Cleanup Task

    Next, select the ‘Sub-plan_2’ in the maintenance plan. Drag over ‘Maintenance Cleanup Task’ onto the white space and place it under the transaction log backup.

    3348.1[1]_thumb[1]

    Right Click on the ‘Maintenance Cleanup Task’ and choose edit.

    8535.2[1]_thumb[1]

    This section allows you to setup the maintenance cleanup task. This task will clean up the transaction logs after three days. This will keep the one hour transaction logs for three days until the maintenance cleanup task deletes the old data. The transaction log clean up will need to include a series of Three days, this will ensure if you need to revert back to the second differential you can apply the transaction logs from that time period. The goal is to have enough transaction logs in between the full and differential backups.

    1. Choose ‘Backup files’
    2. Choose ‘Search folder and delete files based on an extension.
    3. **Paste in the copied path that you copied earlier.** Make sure you include the same path that your transaction logs are backing up to. And enter the File extension type. (trn). Also include the first-level sub-folders. Use trn not .trn  | it will confuse SQL.
    4. Set the file age to ‘3 days’.
    5. Click ‘OK’ to return to the Management Studio main Screen.

    6562.3[1]_thumb[1]

    Drag the green arrow from the differential backup task to the Maintenance cleanup task. Double click on the connected green line.

    5483.4[1]_thumb[1]

    Configure the value to ‘Completion’. This allows the task to become conditional. “If the differential backup did not run then do not run the transaction cleanup task.” “If the backup did run proceed with the cleanup task.”

    0383.5[1]_thumb[1]

    Click ‘OK’ to return to the Management Studio main screen. You should now see that the green line has become blue.

    1348.6[1]_thumb[1]

    You are now finished with you maintenance task setup. You can adjust you backup plan to your needs. Be sure to save you work. *Save your work by going to file --> Then Save All*********

    3173.7[1]_thumb[1]

    How to test your setup

    After you are done setting up your maintenance plan you will need to verify that it works. You can choose to wait a few days to see if the job completes or you can force the job to run.

    Browse down to ‘Jobs’ under ‘SQL Server Agent’. And right –click on the first maintenance plan and choose ‘Start Job at This Step’.

    3005.1[1]_thumb[1]

    This will run the first section of the maintenance plan you created.

    6710.2[1]_thumb[1]

    At this step if the job completes continue on to the next step of the maintenance plan and test-run the setup. Do this for all sub-plans you created in the maintenance plan. If all of your steps run without error you are finished.

    Errors
    If you jobs fail when you are performing a test-run you will need to view the history to see what failed.
    Right-click on the failed sub-plan and select ‘View History’.

    6114.3[1]_thumb[1]

    This will bring up a new window that shows the history.

    4135.4[1]_thumb[1]

    If your job failed you will see a red X next to the time you ran the job. Drag up the dialog box below to see the details of the error.

    5518.5[1]_thumb[1]

    Troubleshoot the error and repeat the test-job to see if it cleared up. Once your maintenance plan is solid it good practice to check back in a few days to see if it is running the way you want. Check to see if the .bak files are being removed after the expiration. Check to see if the transaction logs are being clean up after three days.

    转:https://community.rackspace.com/products/f/25/t/210
  • 相关阅读:
    sql 2008 r2
    js压缩反压缩
    .NET调用Java写的WebServices(可能会碰到的问题)
    ecshop
    Chrome插件
    Unity3d ShaderLab之WorldNormalVector
    Unity 3d中Shader是什么,可以吃吗?
    java,类的继承
    java,关于POJO,查阅资料
    java,编写一个汽车类
  • 原文地址:https://www.cnblogs.com/shuaixf/p/3403826.html
Copyright © 2011-2022 走看看