共用方式為


Windows Server Backup Step-by-Step Guide for Windows Server 2008 R2

Applies To: Windows Server 2008 R2

Windows Server Backup is a feature in the Windows Server 2008 and Windows Server 2008 R2 operating systems that provides a set of wizards and other tools that you can use to perform backup and recovery operations on your server.

About this guide

This document provides instructions for performing some new scenarios that use features that are added in Windows Server Backup in Windows Server 2008 R2. For additional information about Windows Server Backup and other backup and recovery tools in Windows Server 2008, see the Windows Server 2008 Technical Library (https://go.microsoft.com/fwlink/?LinkID=134698).

The instructions in this guide take several hours to complete. After you complete the steps in this guide, you will be able to:

  • Perform a backup of selected files and folders of your server.

  • Create a system state backup of your server.

  • Perform a system state recovery of your server.

  • Set up a scheduled backup of the system state and other selected files of your server, and store it on a local volume.

  • Set up a scheduled backup of the system state and other selected files of your server, and store it on a remote shared folder.

  • Perform a backup while excluding some files of your server based on file path or file type.

  • Use Windows PowerShell to run an on-demand backup.

  • Use Windows PowerShell to set up a scheduled backup of your server.

  • Use Windows PowerShell to modify an existing scheduled backup configuration.

This guide does not provide the following:

Requirements for using Windows Server Backup

To complete the steps in this guide, you must have a computer running a full installation of any edition of Windows Server 2008 R2 (not a Server Core installation). (Windows Server Backup is available on all editions of Windows Server 2008 and Windows Server 2008 R2. However, the Windows Server Backup snap-in is not available for the Server Core installation option of these operating systems. To run backups for computers with a Server Core installation, you need to use the command line or manage backups remotely from another computer that is running a full installation of Windows Server 2008 R2.)

To install Windows Server Backup, log on to the computer by using the local Administrator account or another account with Administrator privileges.

To perform backups or recoveries by using Windows Server Backup, you must be a member of the Administrators or Backup Operators groups.

For additional requirements and considerations, see What's New in Windows Server Backup (https://go.microsoft.com/fwlink/?LinkID=178236).

Installing and accessing Windows Server Backup in Windows Server 2008 R2

This section contains the following instructions:

  • To install and open backup and recovery tools

  • To open an elevated Windows PowerShell window

  • To add the Windows Server Backup cmdlet snap-in to Windows PowerShell

  • To view a list of Windows Server Backup cmdlets

  • To view Help for Windows Server Backup cmdlets

To access all backup and recovery tools, you must install the Windows Server Backup Features and both subordinate items (Windows Server Backup and Command-line Tools) that are available in the Add Features Wizard in Server Manager. This installs the following tools:

  • Windows Server Backup Microsoft Management Console (MMC) snap-in (installed by selecting Windows Server Backup)

  • Wbadmin command-line tool (installed by selecting Windows Server Backup)

  • Windows PowerShell cmdlets for Windows Server Backup (installed by selecting Command-line Tools)

To install and open backup and recovery tools

  1. Click Start, click Administrative Tools, and then click Server Manager. In the left pane, click Features, and then in the right pane, click Add Features. This opens the Add Features Wizard.

  2. In the Add Features Wizard, on the Select Features page, expand Windows Server Backup Features, and then select the check boxes for Windows Server Backup and Command-line Tools.

Note

If you want to install only the snap-in and the Wbadmin command-line tool, expand Windows Server Backup Features, and then select the Windows Server Backup check box only—make sure the Command-line Tools check box is clear.

  1. On the Confirm Installation Selections page, review the choices that you made, and then click Install. If there is an error during the installation, it is noted on the Installation Results page.

After the installation, you can access the Windows Server Backup tools as follows:

  • To access the Windows Server Backup snap-in, click Start, click Administrative Tools, and then click Windows Server Backup.

  • To view a list of available subcommands and the syntax for Wbadmin, click Start, right-click Command Prompt, and then click Run as administrator. At the prompt, type: wbadmin /?.

  • To access the cmdlets, each time you open an instance of Windows PowerShell, you must add the Windows Server Backup cmdlet snap-in to that instance, as described in the procedures below. (Alternatively, you can start Windows PowerShell so that all the Windows PowerShell modules and snap-ins are loaded automatically. To do this, right-click the Windows PowerShell icon in the taskbar, and then click Import all modules. In Windows Server 2008 R2, the Windows PowerShell icon is pinned to the taskbar by default. However, you must start Windows PowerShell one time to make the Import all modules task appear.)

To open an elevated Windows PowerShell window

  • Click Start, point to All Programs, point to Accessories, point to Windows PowerShell, right-click Windows PowerShell V2, and then click Run as administrator. The elevated Windows PowerShell window opens.

To add the Windows Server Backup cmdlet snap-in to Windows PowerShell

  1. To add the snap-in, at the Windows PowerShell prompt, type:

    add-pssnapin windows.serverbackup

  2. To confirm that the snap-in was added, at the Windows PowerShell prompt, type:

    get-pssnapin

    Then look for windows.serverbackup in the output.

To view a list of Windows Server Backup cmdlets

  • At the Windows PowerShell prompt, type:

    get-command -module windows.serverbackup

To view Help for Windows Server Backup cmdlets

  • At the Windows PowerShell prompt, type the following:

    • To display basic Help, type: Get-Help*<cmdlet_name>*

    • To display detailed Help, type: Get-Help*<cmdlet_name>*-detailed

    • To display examples for a cmdlet, type: Get-Help*<cmdlet_name>*-examples

    • To display all Help for a cmdlet, type: Get-Help*<cmdlet_name>*-full

Changes in protecting your system and backup storage locations

In Windows Server 2008 R2 you can use the Windows Server Backup user interface (MMC snap-in), the Wbadmin command, or the Windows PowerShell cmdlets for Windows Server Backup to back up selected files and folders, back up just the system state, exclude files from a backup based on type or location, create a backup for bare metal recovery, or save scheduled backups to remote shared folders. You can use the Windows Server Backup user interface or the Wbadmin command to perform recovery operations. (You cannot use the Windows PowerShell cmdlets for Windows Server Backup to perform recovery operations.)

This section contains the following example procedures:

  • To create a one-time backup of selected files and folders

  • To create a one-time backup that can be used to perform a bare metal recovery

  • To create a scheduled system state backup of your server

  • To perform a system state recovery of your server

  • To exclude files from a backup based on path and file type

New in Windows Server 2008 R2, you can use the Windows Server Backup user interface (the Backup Schedule Wizard or Backup Once Wizard), the Wbadmin command-line tool, or the Windows PowerShell cmdlets for Windows Server Backup to back up certain files and folders if you do not want to back up entire volumes. You can then store the backup on an attached hard disk drive, a volume, DVDs or other removable or optical media, or a remote shared folder. The following example procedure uses the Backup Once Wizard and a volume for backup storage.

To create a one-time backup of selected files and folders

  1. Click Start, click Administrative Tools, and then click Windows Server Backup.

  2. From the Actions pane of the snap-in default page, under Windows Server Backup, click Backup Once. This opens the Backup Once Wizard.

  3. On the Backup Options page, click Different options, and then click Next.

  4. On the Select Backup Configuration page, click Custom, and then click Next.

  5. On the Select Items for Backup page, click Add Items. In Select Items, select the check boxes for the items that you want to back up. (If the volumes selected are not formatted as NTFS, you will receive a message.) To back up just certain folders or files, expand the folder tree and select the items that you want to include. Click OK.

  6. On the Specify Destination Type page, click Local drives, and then click Next.

  7. On the Select Backup Destination page, select the volume from the drop-down list that you want to use to store the backup. (You should confirm that there is enough free space on the volume.)

  8. On the Confirmation page, review the details, and then click Backup. The wizard prepares the backup set and checks the volume.

  9. On the Backup Progress page, you can view the status of the backup.

New in Windows Server 2008 R2, you can use the Windows Server Backup user interface (the Backup Schedule Wizard or Backup Once Wizard), in addition to the Wbadmin command-line tool or the Windows PowerShell cmdlets for Windows Server Backup, to create a backup. You can later use this backup with the Windows Recovery Environment to perform a bare metal recovery. You can store backups for bare metal recovery on an attached hard disk drive, a volume, DVDs or other removable or optical media, or a remote shared folder. (We recommend that you store backups for bare metal recovery on a media type that can be moved off site.) This example procedure uses the Backup Once Wizard and an attached hard disk drive for storage.

To create a one-time backup that can be used to perform a bare metal recovery

  1. Click Start, click Administrative Tools, and then click Windows Server Backup.

  2. From the Actions pane of the snap-in default page, under Windows Server Backup, click Backup Once. The Backup Once Wizard opens.

  3. On the Backup Options page, click Different options, and then click Next.

  4. On the Select Backup Configuration page, click Custom, and then click Next.

Note

If you click Full server (recommended) in this step instead of Custom, the items that are needed for a bare metal recovery are automatically included in the backup (along with the system state and all volumes).

  1. On the Select Items for Backup page, click Add Items. In Select Items, select the Bare metal recovery check box, click OK, and then click Next.

  2. On the Specify Destination Type page, click Local drives, and then click Next.

  3. On the Select Backup Destination page, select the attached hard disk drive from the drop-down list that you want to use to store the backup. (You should confirm that there is enough free space on the attached hard disk drive.)

  4. On the Confirmation page, review the details, and then click Backup. The wizard prepares the backup set and checks the disk.

  5. On the Backup Progress page, you can view the status of the backup.

New in Windows Server 2008 R2, you can use the Windows Server Backup user interface (the Backup Schedule Wizard or Backup Once Wizard), in addition to the Wbadmin command-line tool or the Windows PowerShell cmdlets for Windows Server Backup, to create a backup of the system state of your server. You can store system state backups on an attached hard disk drive, a volume, or a remote shared folder. You cannot store system state backups or scheduled backups on DVDs, optical media, or other removal media. If you use a volume instead of dedicating an entire hard disk to store backups, the volume is not reformatted before the backup is written to it. However, the performance of the volume may be impacted if you store other data on the volume. This example procedure uses the Backup Schedule Wizard and a volume for storage.

To create a scheduled system state backup of your server

  1. Click Start, click Administrative Tools, and then click Windows Server Backup.

  2. In the Actions pane of the snap-in default page, under Windows Server Backup, click Backup Schedule. This opens the Backup Schedule Wizard.

  3. On the Getting Started page, click Next.

  4. On the Select Backup Configuration page, click Custom, and then click Next.

  5. On the Select Items for Backup page, click Add Items. In Select Items, select the System state check box, click OK, and then click Next.

Note

You can also include additional items in a system state backup by selecting the check boxes for those items.

  1. On the Specify Backup Time page, do one of the following, and then click Next:

    • Click Once a day, and then select the time from the drop-down list to start running the daily backup.

    • Click More than once a day. Then to select a start time, under Available time, click the time that you want the backup to start, and click Add to move the time under Scheduled time. Repeat this step for each start time that you want to add.

  2. On the Specify Destination Type page, select Back up to a volume.

  3. Select Back up to a volume. On the Select Destination Volume page, click Add. In Add volumes, click the volume(s) that you want to use, and then click OK.

Note

You cannot select multiple volumes on the same disk to store backups. You can only add one volume per disk. Support for multiple volumes is for the situation where you use multiple disks to store backups that are shared between multiple servers or that contain other data that you do not want deleted. If the first volume in the list becomes unavailable, then scheduled backups are stored on the next volume in the list.

  1. On the Confirmation page, review the details, and then click Finish. If you dedicated a disk for storage, the wizard formats the disk, which may take several minutes depending on the size of the disk.

  2. On the Summary page, click Close.

New in Windows Server 2008 R2, you can use the Windows Server Backup user interface (the Recovery Wizard), in addition to the Wbadmin command-line tool, to perform a system state recovery. Before you begin, you should make sure that you have a backup of a server that includes the system state (a system state backup, a bare metal recovery backup, or a full server backup). This example procedure uses a backup stored on a remote shared folder to recover the system state to the original location.

To perform a system state recovery of your server

  1. From the Start menu, click Administrative Tools, and then click Windows Server Backup.

  2. In the Actions pane of the snap-in default page, under Windows Server Backup, click Recover. This opens the Recovery Wizard.

  3. On the Getting Started page, click A backup stored on another location. On the Specify Location Type page, click Remote shared folder.

  4. On the Specify Remote Folder page, type the path to the folder that contains the backup. (In the folder, the backup is stored at \\<RemoteSharedFolder>\WindowsImageBackup\<ComputerName>\<YourBackup>.) Then click Next.

  5. On the Select Backup Date page, select the date from the calendar and the time from the drop-down list of the backup that you want to restore from, and then click Next.

  6. On the Select Recovery Type page, click System state, and then click Next.

Note

The System state option can appear disabled if the backup that you selected in Select Backup Date did not contain the system state. To continue, click Back and then select a backup that includes the system state.

  1. On the Select Location for System State Recovery page, click Original location, and then click Next.

  2. On the Confirmation page, review the details, and then click Recover to restore the listed items.

  3. On the Recovery Progress page, you can view the status of the recovery operation and whether or not it successfully completed. After the operation completes, you must restart your computer to replace the files that were in use.

Warning

You cannot stop the system state recovery after you start it. If you attempt to stop it, the system cannot boot. Wait until you are prompted before you restart the computer.

New in Windows Server 2008 R2 you can use the Windows Server Backup user interface (the Backup Schedule Wizard or Backup Once Wizard), the Wbadmin command-line tool, or the Windows PowerShell cmdlets for Windows Server Backup to exclude certain files, file locations, or file types from your backup. You can then store the backup on an attached hard disk drive, a volume, DVDs or other removable or optical media, or a remote shared folder. This example procedure uses the Backup Schedule Wizard and a remote shared folder for backup storage.

Important

Do not choose this option if you want to store multiple backups. If you store your backup in a remote shared folder, Windows Server Backup overwrites your backup each time you create a new backup. Also, if you create a backup to a remote shared folder that already contains a backup, if the backup process fails, you might be left without any backups.

To exclude files from a backup based on path and file type

  1. Click Start, click Administrative Tools, and then click Windows Server Backup.

  2. In the Actions pane of the snap-in default page, under Windows Server Backup, click Backup Schedule. This opens the Backup Schedule Wizard.

  3. On the Getting Started page, click Next.

  4. On the Select Backup Configuration page, click Custom and then click Next.

  5. On the Select Items for Backup page, click Add Items. In Select Items, select the check boxes for the items that you want to back up and then click OK.

  6. Again on the Select Items for Backup page, click Advanced Settings, click the Exclusions tab, click Add Exclusions, and then expand the folder tree and select the items that you want to exclude.

  7. On the Specify Backup Time page, do one of the following, and then click Next:

    • Click Once a day, and then select the time from the drop-down list to start running the daily backup.

    • Click More than once a day. Then to select a start time, under Available time, click the time that you want the backup to start, and click Add to move the time under Scheduled time. Repeat this step for each start time that you want to add.

  8. On the Specify Destination Type page, select Back up to a shared network folder.

  9. On the Specify Remote Shared Folder page, type the path to the folder. A folder named WindowsImageBackup is created. The backup that you create is saved at the following location: \\<RemoteServer>\<SharedFolderPath>\WindowsImageBackup\<ComputerBackedUp>. Click Next.

  10. The Register Backup Schedule dialog box appears. Type a user name and password for a user account that is a member of the Administrators group or Backup Operators group and has write permissions on the computer that is hosting the remote shared folder, and then click OK.

  11. On the Confirmation page, review the details, and then click Finish.

  12. On the Summary page, click Close.

Changes in managing backups by using Windows PowerShell

This section contains the following scenarios:

  • To create and configure Windows PowerShell objects for backups

  • To use Windows PowerShell to run a one-time backup

  • To use Windows PowerShell to configure a scheduled backup

You can use the Windows PowerShell cmdlets for Windows Server Backup to create a backup policy object (WBPolicy object). You can then create and configure additional objects (for example, WBFileSpec objects and WBBackupTarget objects) and set attributes to define what you want your backups to contain, when you want to run backups for your organization, and where you want to store your backups, and then add these objects and attributes to the backup policy WBPolicy object.

This example procedure explains the overall process for creating and configuring a backup policy. For the full syntax for these cmdlets, see Windows Server Backup Cmdlets in Windows PowerShell (https://go.microsoft.com/fwlink/?LinkID=137655).

To create and configure Windows PowerShell objects for backups

  1. Click Start, point to All Programs, point to Accessories, point to Windows PowerShell, right-click Windows PowerShell V2, and then click Run as administrator. An elevated Windows PowerShell window opens.

  2. At the Windows PowerShell prompt, to add the Windows Server Backup Windows PowerShell snap-in to the session, type:

    Add-PsSnapin Windows.ServerBackup

  3. To create a new backup policy (WBPolicy) object and store it inside a variable $policy, type:

    $policy=New-WBPolicy

  4. Create a file spec object and then define the items to include in the backup policy by typing one or more of the following:

    • To create a WBFileSpec object that represents a file (for example, c:\dir1\a.txt) to be included in the backup, type:

      $filespec1=New-WBFileSpec –FileSpec c:\dir1\a.txt

    • To create a WBFileSpec object that represents a folder (for example, c:\dir2) to be included in the backup, type:

      $filespec2=New-WBFileSpec –FileSpec c:\dir2

    • To create a WBFileSpec object that represents a file type (for example, all *.log files under d:) to be included in the backup, type:

      $filespec3=New-WBFileSpec –FileSpec d:\*.log

    • To create an array of WBFileSpec objects that represents multiple file spec types (for example, specific files, all files in a certain location, and specific file types) (separate the parameters using commas (,)), type:

      $ListOfFileSpecs=New-WBFileSpec –FileSpec c:\dir1\a.txt, c:\dir2, d:\*.log

  5. To include a WBFileSpec object or an array of WBFileSpec objects (for example, $ListOfFileSpecs) that you defined in the backup policy, type:

    Add-WBFileSpec –Policy $policy –FileSpec $ListOfFileSpecs

  6. Specify items to exclude from the backup by creating one or more of the following file spec exclusion objects:

    • To specify that a particular file (for example c:\users\abc\archive.pst) should be excluded from the backup, type:

      $ExclusionFilespec1=New-WBFileSpec –FileSpec c:\users\abc\archive.pst -Exclude

    • To specify that a particular folder (for example c:\logs) should be excluded from the backup, type:

      $ExclusionFilespec2=New-WBFileSpec –FileSpec c:\logs -Exclude

    • To specify that a particular file type (for example *.mp3) should be excluded from the backup under a certain volume (for example volume c:), type:

      $ExclusionFilespec3=New-WBFileSpec –FileSpec c:\*.mp3 -Exclude

    • To create an array of WBFileSpec exclusion objects that contains multiple types of items (for example, specific files, all files in a certain location, and specific file types) (separate the parameters using commas (,)), type:

      $ExclusionListOfFileSpecs=New-WBFileSpec –FileSpec c:\users\abc\archive.pst, c:\logs, c:\*.mp3 -Exclude

  7. To include a WBFileSpec exclusion object or an array of WBFileSpec exclusion objects (for example, $ExclusionListOfFileSpecs) in the backup policy, type:

    Add-WBFileSpec –Policy $policy –FileSpec $ExclusionListOfFileSpecs

  8. Specify a backup storage location. Create a WBBackupTarget object by typing one of the following:

    • To specify that a particular volume (for example, volume G) should be used as the backup storage location, type:

      $BackupTargetVolume=New-WBbackupTarget –VolumePath G:

    • To specify that a particular remote shared folder (for example \\server\share\folder) should be used as the backup storage location, type:

      $BackupTargetNetwork=New-WBbackupTarget –NetworkPath \\server\share\folder

  9. To include a WBBackupTarget object that you have defined (for example $BackupTargetVolume) in the backup policy $policy, type:

    Add-WBBackupTarget –Policy $policy –Target $BackupTargetVolume

  10. Add the system state to, or remove the system state from, the backup policy by typing one of the following:

    • To specify that the backup policy object $policy should include the system state, type:

      Add-WBSystemState –Policy $policy

    • To remove the system state from the backup policy, type: Remove-WBSystemState –Policy $policy

  11. Add the capability for bare metal recovery to, or remove the capability for bare metal recovery from, the backup policy object $policy by typing one of the following:

    • To specify that the backup policy object should include the capability for bare metal recovery, type:

      Add-WBBareMetalRecovery –Policy $policy

    • To remove the capability for bare metal recovery from the backup policy object, type:

      Remove-WBBareMetalRecovery –Policy $policy

After you create and configure a backup policy object, you can use the object with Windows PowerShell to run a one-time backup. (If you have not already created a backup policy object (WBpolicy), use the previous procedure in this document “To create and configure Windows PowerShell objects for backups” to create one.)

To use Windows PowerShell to run a one-time backup

  • At the Windows PowerShell prompt, type:

    Start-WBBackup –Policy $policy

The following example script demonstrates how to create and then run a backup policy with the following characteristics:

  • Items to back up: All items needed for a bare metal recovery.

  • Backup storage location: Backups saved to volume G.

Before you begin, open an elevated Windows PowerShell window and add the cmdlet snap-in to the session as described in the procedure “To create and configure Windows PowerShell objects for backups,” earlier in this document.

Note

To create a script, you can copy and paste the Command-line column of this table into a text editor, replace the values with values for your organization, and then save the file with a .ps1 extension. Or you can paste the syntax into the Windows PowerShell window by copying the syntax and then clicking the right button at the prompt to paste.

Step Task description Command-line

1

Create a new backup policy object and store it inside the variable $policy.

$policy=New-WBPolicy

2

Specify that the backups be stored on volume G.

$BackupTargetVolume=New-WBbackupTarget –VolumePath G:

3

Specify that the backup policy object should include the capability for bare metal recovery.

Add-WBBareMetalRecovery –Policy $policy

4

Run this backup.

Start-WBBackup –Policy $policy

You can also use the Windows PowerShell cmdlets for Windows Server Backup to create a scheduled backup. To do this, you create a backup policy object, specify the times that you want to run backups, specify what you want to back up, specify where you want to store backups, and then set the backup policy as the one to use for scheduled backups.

To use Windows PowerShell to configure a scheduled backup

  1. Click Start, point to All Programs, point to Accessories, point to Windows PowerShell, right-click Windows PowerShell V2, and then click Run as administrator. This opens an elevated Windows PowerShell window.

  2. At the Windows PowerShell prompt, to add the Windows Server Backup Windows PowerShell snap-in to the session, type:

    Add-PsSnapin Windows.ServerBackup

  3. To create a new backup policy (WBPolicy) object and store it inside the variable $policy, type:

    $policy=New-WBPolicy

  4. To add schedule information, specify in HH:MM format (24-hour clock) the times of day the backup should run. Multiple backup times should be separated by a comma (,). For example, to run the backup at 11:00 and 17:30 every day, type:

    Set-WBSchedule –Policy $policy –Schedule 11:00, 17:30

Note

You cannot schedule backups to run less than once daily.

  1. Create a file spec object, and then define the items to include in the backup policy, by typing one or more of the following:

    • To create a WBFileSpec object that represents a file (for example c:\dir1\a.txt) to be included in the backup, type:

      $filespec1=New-WBFileSpec –FileSpec c:\dir1\a.txt

    • To create a WBFileSpec object that represents a folder (for example c:\dir2) to be included in the backup, type:

      $filespec2=New-WBFileSpec –FileSpec c:\dir2

    • To create a WBFileSpec object that represents a file type (for example all *.log files under d:) to be included in the backup, type:

      $filespec3=New-WBFileSpec –FileSpec d:\*.log

    • To create an array of WBFileSpec objects that represents multiple file spec types (for example, specific files, all files in a certain location, and specific file types) (separate the parameters using commas (,)), type:

      $ListOfFileSpecs=New-WBFileSpec –FileSpec c:\dir1\a.txt, c:\dir2, d:\*.log

  2. To include a WBFileSpec object (for example $filespec2) or an array of WBFileSpec objects that you defined in the backup policy, type:

    Add-WBFileSpec –Policy $policy –FileSpec $filespec2

  3. Specify items to exclude from the backup by creating one or more of the following file spec exclusion objects:

    • To specify that a particular file (for example, c:\users\abc\archive.ps) should be excluded from the backup, type: $ExclusionFilespec1=New-WBFileSpec –FileSpec c:\users\abc\archive.pst -Exclude

    • To specify that a particular folder (for example, c:\logs) should be excluded from the backup, type:

      $ExclusionFilespec2=New-WBFileSpec –FileSpec c:\logs -Exclude

    • To specify that a particular file type (for example, *.mp3) should be excluded from the backup under volume C, type:

      $ExclusionFilespec3=New-WBFileSpec –FileSpec c:\*.mp3 -Exclude

    • To create an array of WBFileSpec exclusion objects that contains multiple types of items (for example, specific files, all files in a certain location, and specific file types) to exclude, (separate the parameters using commas (,)) type:

      $ExclusionListOfFileSpecs=New-WBFileSpec –FileSpec c:\users\abc\archive.pst, c:\logs, c:\*.mp3 -Exclude

  4. To include a WBFileSpec exclusion object (for example, $ExclusionFilespec3) or an array of WBFileSpec exclusion objects in the backup policy, type:

    Add-WBFileSpec –Policy $policy –FileSpec $ExclusionFilespec3

  5. Specify a backup storage location. Create a WBBackupTarget object by typing one of the following:

    • To specify that a particular volume (for example, volume G) should be used as the backup storage location, type:

      $BackupTargetVolume=New-WBbackupTarget –VolumePath G:

    • To specify that a particular remote shared folder (for example, \\server\share\folder) should be used as the backup storage location, type:

      $BackupTargetNetwork=New-WBbackupTarget –NetworkPath \\server\share\folder

  6. To include a WBBackupTarget object that you have defined (for example, $BackupTargetVolume) in the backup policy $policy, type:

    Add-WBBackupTarget –Policy $policy –Target $BackupTargetVolume

  7. Add the system state to, or remove the system state from, the backup policy object by typing one of the following:

    • To specify that a backup policy object should include the system state, type:

      Add-WBSystemState –Policy $policy

    • To remove the system state from a backup policy, type:

      Remove-WBSystemState –Policy $policy

  8. Add the capability for bare metal recovery to, or remove the capability for bare metal recovery from, the policy by typing one of the following:

    • To specify that a backup policy object should include the capability for bare metal recovery, type:

      Add-WBBareMetalRecovery –Policy $policy

    • To remove the capability for bare metal recovery from a backup policy object, type:

      Remove-WBBareMetalRecovery –Policy $policy

  9. To save the policy to use for scheduled backups, type:

    Set-WBPolicy –Policy $policy

  10. Later, if you want to change the settings for a scheduled backup, get the current backup policy object that you used for scheduled backups, and put it in edit mode. To do this, type:

    $Policy=Get-WBPolicy -Editable

The following example script creates a backup policy for scheduled backups with the following characteristics:

  • Backup storage location: Backups saved to volume G.

  • Backup times: Run backups daily at 6:00 and 21:30.

  • Items to back up: Back up the system state only.

Before you begin, open an elevated Windows PowerShell window and add the cmdlet snap-in to the session as described in the procedure “To create and configure Windows PowerShell objects for backups,” earlier in this document.

Warning

To create a script, you can copy and paste the Command-line column of this table into a text editor, replace the values with values for your organization, and then save the file with a .ps1 extension. Or you can paste the syntax into the Windows PowerShell window by copying the syntax and then clicking the right button at the prompt to paste.

Step Task description Command-line

1

Create a new backup policy object and store it inside the variable $policy.

$policy=New-WBPolicy

2

Specify that the backups be stored on volume G.

$BackupTargetVolume=New-WBbackupTarget –VolumePath G:

3

Specify that the backups run daily at 6:00 and 21:30.

Set-WBSchedule –Policy $policy –Schedule 6:00, 21:30

4

Specify that the backups created with the policy contain the system state.

Add-WBSystemState –Policy $policy

5

Specify that the backup policy object is used for backups.

Set-WBPolicy –Policy $policy