DESKTOP

Windows Server 2008 R2 : Perform Backup and Recovery with Command Tools

7/17/2012 3:01:34 PM
You may choose to back up and recover your systems with command-line tools. Specifically, in the case of a Windows Server 2008 R2 Server Core installation, two options are available to you; they are the command-line tool wbadmin.exe (the command-line equivalent of the Windows Server Backup GUI) and PowerShell cmdlets.

Regardless of which tool you use, the techniques, terminology. These tools provide the same capabilities as the GUI for Windows Server Backup. Therefore, you do not need to relearn all the previously mentioned information—the command-line versions are just an alternative way to access the tools.

In this section, you will see how to back up and recover your systems with the command-line tools.

1. Use wbadmin.exe

Using the command-line tool wbadmin.exe provides you with a method to create scripts for backup as well as a method to back up servers like Server Core installations where there is no GUI present. Table 1 describes some of the common switches for the wbadmin.exe backup. For more information on how to use wbadmin.exe, in a command prompt, type the following command and hit Enter:

wbadmin /?

Table 1. wbadmin.exe Common Switches
SwitchExplanation
enable backupAllows you to modify or create a backup schedule
start backupPerforms a one-time backup
get disksLists the current disks available and online
start systemstatebackupAllows you create a system state backup
start recoveryBegins the recovery process from an existing backup

1.1. wbadmin.exe Examples

Here are some examples on how you can use wbadmin.exe to perform the various tasks of backup and recovery.

Before you back up the systems, you will need to see what drives are available on the system. When you create a backup, you can use the drive letter if one exists, or you will need the disk identifier. To see what drives are available, run the following command:

wbadmin get disks

Your output will look similar to Figure 1.

Figure 1. Available online disks

The following command will create a backup of the C and D drives and would occur daily at 4 a.m. and 10 p.m. The backup would be stored on the disk {7caba166-0000-0000-0000-000000000000}.

wbadmin enable backup
-addtarget:{7caba166-0000-0000-0000-000000000000}
-schedule:04:00,22:00 -include:c:,d:

If you wanted the backup to occur just once, the command would look like this:

wbadmin start backup
-backuptarget:{7caba166-0000-0000-0000-000000000000}
-include:c:,d:

The following command would back up the system state to the disk {7caba166-0000-0000-0000-000000000000}:

wbadmin start systemstatebackup
-backuptarget:{7caba166-0000-0000-0000-000000000000}

To be able to restore items with wbadmin.exe, you need to know two things: the backup version identifier and what items are stored in the backup. You use wbadmin get versions to find out what backups you currently have available. Specifically, you are looking for the version identifier, which is formatted as a date and timestamp. You would run the following command to see the items backed up on June 30, 2009, at 2:05 p.m.

wbadmin get items -version:06/30/2009-14:05

The results would look similar to Figure 2.

Figure 2. wbadmin.exe get items

The following command would restore the C volume from the backup taken on June 30, 2009, at 2:05 p.m.:

wbadmin start recovery —version:06/30/2009-14:05
-itemType:Volume -items:c:

2. Use PowerShell

These cmdlets provide another tool to perform your server recovery. If you choose to install the command-line tools for Windows Server Backup, you will have access to the PowerShell backup and restore cmdlets as well. Before you can run these tools, you have to verify the PowerShell snap-in for backing up has been loaded.

To verify the tools have been loaded, run the following command from a PowerShell window. Then verify you see Windows.ServerBackup as the loaded snap-in.

Get-PSSnapin

If you do not see Windows Server Backup in your loaded snap-ins, you will need to run this command:

Add-PSSnapin windows.serverbackup

Working with the PowerShell is quite a bit more complex than working with wbadmin.exe to perform backup tasks. You need to create a PowerShell script to accomplish your tasks. Although PowerShell can be more complex, it does offer some nice flexibility to performing backups. All the capabilities of PowerShell are determined by what backup policy you set. The backup policy for PowerShell is stored in an object called WBPolicy. The WBPolicy object contains all the settings for the backup, including the schedule, backup types, backup targets, and so on.

Working with PowerShell and backup, you need to understand how to set the values for the WBPolicy object. Table 2 describes some of the common PowerShell commands used for backup and recovery and how to set the parameters for WBPolicy. For a full listing of the PowerShell cmdlets for backing up the system, run the following cmdlet:

Get-Command *wb* -CommandType cmdlet

Table 2. PowerShell Backup Cmdlets
cmdletsExplanation
Get-WBPolicyDisplays the current settings for the WBPolicy object on the server
Set-WBPolicyAllows you to set the parameters for the WBPolicy
Add-WBVolumeAdds a volume to the WBPolicy object to be backed up
Add-WBSystemStateAdds the system state to the WBPolicy object to be backed up
Set-WBScheduleSets the time for your daily backup schedule
Start-WBBackupStarts a one-time backup
Get-WBJobShows the current status of a running backup job

2.1. PowerShell Examples

As you can see in Table 8.5, only a few of the commands are available to work with PowerShell in Group Policy. This section gives a couple of examples to allow you to get used to using PowerShell.

The following two lines will back up your system with your current backup policy settings. You can create a PowerShell script to run these commands, or you can run each line separately by hitting Enter after each line:

$policy = Get-WBPolicy
Start-WBBackup -Policy $policy

This first line sets the $policy variable to the current settings in WBPolicy. The second line starts the backup process with settings currently in the WPObject object's $policy variable.

The following script will back up the C, D, and system state on your system to your Z drive. Notice you will be using a variety of the Add cmdlets to modify the value of the variable $policy, as well as variables for target and paths:

$policy = New-WBPolicy
$volume = Get-WBVolume -VolumePath c:
Add-WBVolume -Policy $policy -volume $volume
$volume1 = Get-WBVolume -VolumePath d:

Add-WBVolume -Policy $policy -volume $volume1
Add-WBSystemState -Policy $policy
$target = New-WBBackupTarget -VolumePath Z:
Add-WBBackuptarget -Policy $policy -target $target
Start-WBBackup -Policy $policy
Other  
  •  Elgato Thunderbolt Ssd 120gb
  •  CM Storm – Quick Fire Rapid
  •  By Design: Just Mobile Accessory = Efficiency!
  •  Big Print Possible
  •  Too Many Driver Updates
  •  PNY – Nvidia GeForce GTX 670 2GB
  •  Coolermater Hyper 412 Slim CPU Cooler
  •  Asus Rog Tytan CG8565 - Clash Of The Tytan
  •  Asus EEEPC X101CH - A Place For Netbooks?
  •  MacBook Pro with Retina display screen release
  •  MacBook Air and Pro are upgraded with Core i Ivy Bridge and USB 3.0
  •  Water Cools The PC Better
  •  Acer Aspire Timeline Ultra M3-581TG : Ultra-Size, Ultra-Power
  •  MSI GT70 : Turbo-Charged Gaming
  •  Kingston HyperX BLU 8GB RAM : The Blu of affordability and performance
  •  Kingston HyperX 3K SSD : SSD For The Budget Conscious
  •  AMD Radeon HD7750 : Single slot awesomeness
  •  HP Omni 27
  •  WD's My Passport (2TB) - Never leave home without it
  •  HP X2301 : Micro Thin, Macro Sights
  •  
    Top 10
    Switching to Microsoft Windows 7 : Migrating Applications and Data to a New Windows 7 Computer (part 2)
    Switching to Microsoft Windows 7 : Migrating Applications and Data to a New Windows 7 Computer (part 1)
    Switching to Microsoft Windows 7 : Migrating Data on a Single Computer
    Using the Android Development Environment for Real Applications (part 2)
    Using the Android Development Environment for Real Applications (part 1)
    BenQ GW2750HM - Great Performance For Its Price
    LG LM9600 47” Smart TV - A New Direction
    The Download Directory - November 2012 (Part 3) - Multiplicity 2.0, LastPass Password Manager 2.0.0
    The Download Directory - November 2012 (Part 2) - UltraVNC 1.1.0.0 Beta, Firefox 16 Beta 3, BlueScreenView 1.45 Description: BlueScreenView
    The 3DS XL : Super-Sized!
    Most View
    Use Preview to Edit On Your Mac (Part 2)
    Examining Integration Points Between SharePoint and Public Key Infrastructure
    Exchange Server 2010 and Active Directory
    Get more from your music : Step-by-step take control of your music
    Every Cloud...(Part 3) - Sharing/Team Features
    ASP.NET 4 in VB 2010 : Membership - Role-Based Security
    Panasonic HC-V700
    Tough Phones : Work or play in harsh environments
    Adobe Photoshop CS5 : Working with Automate Commands - Merging Images to HDR
    Philips W632 ICS Smartphone
    SSD Redefined
    Yamaha BDX-610 - Home Cinema
    iOS 6 Beta Review (Part 1)
    Microsoft ASP.NET 4 : Configuring ASP.NET from IIS
    Microsoft XNA Game Studio 3.0 : Displaying Images - Using Resources in a Game (part 2) - Positioning Your Game Sprite on the Screen
    Algorithms for Compiler Design: ELIMINATING INDUCTION VARIABLES
    Sennheiser New Wireless Headphones : PXC 360 BT, MM550 –
    Programming the Mobile Web : Content Delivery (part 2) - File Delivery
    Mobile Application Security : SymbianOS Security - Application Packaging
    In Search Of The Perfect Mid-Tower (Part 1) - Antec Eleven Hundred, Silverstone Temjin Tj04-E