IT tutorials
 
Windows
 

Windows Small Business Server 2011 : Using the Command Line to Manage Backups

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/5/2013 3:49:46 AM

There are two ways to do backups from the command line—using Windows PowerShell or using the Wbadmin command. Personally, we much prefer using Windows PowerShell for everything we can, but there are limitations here. The PowerShell interface to backups is done through a PowerShell snap-in, and this snap-in does not provide any interface to doing restores, only backups. This isn’t a huge problem because in the vast majority of cases you don’t need to automate restores, but you can and should be automating backups.

The other significant limitation of Windows PowerShell support for managing backups is that it isn’t available on the Microsoft Hyper-V Server. This means that you can’t use Windows PowerShell to manage your backups on the Microsoft Hyper-V Server if you’re using that as your virtualization solution. You’ll need to use the Wbadmin command.

1. Using the Windows.Serverbackup PowerShell Snap-in

Windows Server Backup includes the Windows.Serverbackup PowerShell snap-in. This snap-in includes the cmdlets necessary to configure and manage backups on the SBS server. Table 1 includes a list of the cmdlets included in the snap-in.

Table 1. The cmdlets in the Window.Serverbackup snap-in
NAMESYNOPSIS
Get-WBDiskReturns a list of internal and external disks that are attached to the local computer.
Get-WBVolumeReturns a list of volumes that are included in the current backup policy.
Add-WBVolumeAdds volumes to the current backup policy.
Remove-WBVolumeRemoves volumes from the current backup policy.
New-WBPolicyCreates a new backup policy (WBPolicy object).
Get-WBPolicyReturns the current backup policy for the computer.
Set-WBPolicySets a WBPolicy object as the current backup policy for scheduled backups.
Remove-WBPolicyDeletes the current backup policy.
Get-WBSummaryReturns a history of backup operations.
New-WBBackupTargetCreates a new backup location.
Get-WBBackupTargetReturns the current backup target locations.
Add-WBBackupTargetAdds a backup target location to the backup policy.
Remove-WBBackupTargetRemoves the backup target locations from the backup policy.
Get-WBScheduleReturns the current backup schedule for backups.
Set-WBScheduleSets the times for daily backups.
Get-WBBackupSetReturns the list of backups.
Start-WBBackupInitiates a one-time backup.
Get-WBJobReturns the currently running backup job.
New-WBFileSpecCreates a new WBFileSpec object. FileSpec objects describe files, folders, and volumes that are included or excluded from the backup.
Add-WBFileSpecAdds the WBFileSpec object to the backup policy.
Remove-WBFileSpecRemoves the WBFileSpec object (and the files, folders, and volumes that it includes or excludes) from the backup policy.
Get-WBFileSpecReturns a list of WBFileSpec objects associated with the backup policy.
Add-WBSystemStateAdds the necessary items to the backup policy to allow for system state recovery.
Get-WBSystemStateReturns $true if system state is part of the backup policy.
Remove-WBSystemStateRemoves system state from the backup policy.
Add-WBBareMetalRecoveryAdds the necessary items to the backup policy to ensure a full bare-metal recovery.
Get-WBBareMetalRecoveryReturns $true if the backup policy includes the necessary items to ensure a full bare-metal recovery.
Remove-WBBareMetalRecoveryRemoves the necessary items from the backup policy that ensure a bare-metal recovery.
Set-WBVssBackupOptionsSets the VSS backup type for the backup policy.
Get-WBVssBackupOptionsReturns the VSS backup type for the backup policy.

The process of defining and using Windows PowerShell to manage backups requires first creating the Windows Backup policy object and then configuring it with one or more file specification objects (WBFileSpec), a schedule object (WBSchedule), system state and bare-metal recovery options, and a Volume Shadow Service (VSS) backup type. So, to define a full-server backup to the network share \\wss-200\serverbackup that included all the files on volumes C and D except those in \temp, and included the necessary files for bare-metal and system state recovery, using a VSS backup type of VSS Full Backup, the PowerShell script would be:

# Script to set a Windows Server Backup policy for SBS
# Created 27/12/2010
# Assumes: Volumes C:, D: and E: to backup.
#        : Target - \\wss-200\serverbackup
#        : Exclusions - D:\temp, E:\temp
#        : VSS Mode - Full Backup
#        : System State - True
#        : Bare Metal Recovery - True
#        : Schedule - 12:30 PM, 9:00 PM
# ModHist: 27/12/10 - initial
#        : 28/12/10 - Final
#

# The following will error if already loaded, but continue, so ignore
Add-PSSnapin Windows.ServerBackup

# First, create a new empty policy
$BackupPolicy = New-WBPolicy


# Now, define the parts of it.
# First, let's do the volumes. This requires us to first get a list of them,
# and then parse that list to add the ones we want (C:, D: and E:)
# We don't actually need C:, since we'll get that as part of Bare Metal Restore,
# but we include it anyway for completeness

$volC = Get-WBVolume -AllVolumes | Where {$_.MountPath -eq "C:"}
$volD = Get-WBVolume -AllVolumes | Where {$_.MountPath -eq "D:"}
$volE = Get-WBVolume -AllVolumes | Where {$_.MountPath -eq "E:"}
$Volumes = $volC,$volD,$volE

# now, add that to the blank policy
Add-WBVolume -policy $BackupPolicy -volume $Volumes

#Define the Exclusions.
$excD = New-WBFileSpec -Filespec D:\Temp -exclude
$excE = New-WBFileSpec -Filespec E:\Temp -exclude
$FileExclusions = $excE,$excD


# and then add that to the policy we're building
Add-WBFileSpec -policy $BackupPolicy -filespec $FileExclusions


# Define the backup target
# First, you need to create a credential to connect to the remote share
# You can specify the username here (DOMAIN\User) but will be
# prompted for the password
$Cred = Get-Credential example\Charlie


# Now, define the target
$Target = New-WBBackupTarget -NetworkPath \\WSS-200\ServerBackup -Credential $Cred

# Add the target to the policy
Add-WBBackupTarget -policy $BackupPolicy -target $Target


# Define the schedule
$sch1 = [datetime]"12/27/2010 12:30:00"
$sch2 = [datetime]"12/27/2010 21:00:00"
Set-WBSchedule -policy $BackupPolicy -schedule $sch1,$sch2


# Set for system state and for bare metal recovery
Add-WBSystemState -policy $BackupPolicy
Add-WBBareMetalRecovery -policy $BackupPolicy


# Finally, set for full VSS Backup
Set-WBVssBackupOptions -policy $BackupPolicy -VssFullBackup


# Finally, we need to SET the policy before it actually takes control
Set-WBPolicy -force -policy $BackupPolicy


# This completes the configuration of the SBS server backup policy
$SBSname = (hostname).tolower()


" The SBS Server $SBSname now has the following backup configuration: "
""

Get-WBPolicy

					  

2. Using the Wbadmin Command

The Wbadmin command allows you to back up and restore volumes and files from the command line. Wbadmin replaces the Ntbackup command that was part of SBS 2003. You can’t use Wbadmin to recover backups created with Ntbackup. However, if you need to recover backups made with Ntbackup, you can download a version of Ntbackup usable with Windows Server 2008 R2. This downloadable version of Ntbackup allows you to perform recoveries of legacy backups, but you cannot use it on Windows Server 2008 R2 to create new backups. To download this version of Ntbackup, see http://go.microsoft.com/fwlink/?LinkId=82917.

The next sections list Wbadmin commands and syntax. Table 2 lists and describes the parameters used with Wbadmin. For additional assistance, type Wbadmin /? at a command prompt.


Note:

Not all the Wbadmin commands are visible from the command line. Certain commands are available only from the Windows Recovery Environment, or are hidden but available for use. For the complete Command Reference see http://go.microsoft.com/fwlink/?LinkId=93131.


Table 2. Wbadmin parameters
PARAMETERDESCRIPTION
-addtargetStorage location for backup. Disk is formatted before use and any existing data on it is permanently erased.
-allCriticalAutomatically includes all critical volumes (volumes that contain system state data). Can be used along with the -include option.
-backupTargetStorage location for this backup. Requires a hard disk drive letter (f:) or a Universal Naming Convention (UNC) path to a shared network folder (\\servername\sharename). If a shared network folder is specified, this backup will overwrite any existing backup in that location.
-dfsAuthMarks the restore as authoritative. Can be used only when the server being recovered is hosting folders that are being replicated by Distributed File System Replication (DFSR). This parameter makes the recovered version of the replicated folders the authoritative copy, thereby overwriting the version stored on other members of the replication group. If this parameter is not used, the data is restored as a nonauthoritative copy.
-excludeDisksCan be used only with the -recreateDisks parameter. Must be input as a comma-delimited list of disk identifiers (as listed in the output of wbadmin get disks). Excluded disks are not partitioned or formatted. This parameter helps preserve data on disks that you do not want modified during the recovery.
-includeComma-delimited list of volume drive letters, volume mount points, or GUID-based volume names to include in the backup.
-noInheritAclIf specified, the computer-name folder applies ACLs for the user whose credentials were given when running the backup and grants access to the Administrators group and Backup Operators group on the computer with the shared network folder. If -noInheritAcl is not used, the ACL permissions from the remote shared folder are applied to the <ComputerBackedUp> folder by default so that anyone with access to the remote shared folder can access the backup.
-itemsComma-delimited list of volumes, applications, and files to recover.

If -itemtype is Volume, it can be only a single volume that is specified by providing the volume drive letter, volume mount point, or GUID-based volume name.

If -itemtype is App, it can be only a single application. Applications that can be recovered include SQL Server and Windows SharePoint Services. You can also use the value ADExtended to recover an installation of Active Directory.

If -itemtype is File, it can be files or directories, but it should be part of the same volume and it should be under the same parent.
-itemtypeType of items to recover. Must be Volume, App, or File.
-machineSpecifies the name of the computer for which you want to recover the backup. Should be used when -backupTarget is specified.
-notrestoreaclCan be used only when recovering files. Specifies to not restore the security ACLs of the files being recovered from backup. By default, the security ACLs are restored. (The default value is true.) If this parameter is used, the default ACLs for the location that the files are being restored to are applied.
-noVerifyIf specified, backups written to removable media (such as a DVD) are not verified for errors. If not specified, backups written to such media are verified for errors.
-overwriteValid only when recovering files. Specifies the action to take when a file that is being recovered already exists in the same location.

Overwrite causes the recovery to overwrite the existing file with the file from the backup.

CreateCopy causes the recovery to create a copy of the existing file so that the existing file is not modified.

Skip causes the recovery to skip the existing file and continue with recovery of the next file.
-passwordPassword for the user name that is specified by the parameter -user.
-recoveryTargetSpecifies the drive to restore to. Use if this drive is different than the one that was previously backed up. Can also be used for restorations of volumes, files, or applications. If you are restoring a volume, you can specify the volume drive letter of the alternate volume. If you are restoring a file or application, you can specify an alternate backup path.
-recreateDisksRestores a disk configuration to the state that existed when the backup was created.
-recursiveCan be used only when recovering files. Recovers the files in the folders and all files subordinate to the specified folders. By default, only files that reside directly under the specified folders are recovered.
-removetargetStorage location specified in the existing backup schedule.
-restoreAllVolumesRestores all volumes from the selected backup. If this parameter is not specified, only critical volumes (volumes that contain system state data) are restored from the selected backup. Useful when you need to restore noncritical volumes during system recovery.
-scheduleComma-delimited times of day specified as HH:MM.
-showsummaryCan be used only with Wbadmin start sysstaterecovery. Reports the summary of the last run of this command. This parameter cannot be accompanied by any other parameters.
-skipBadClusterCheckCan be used only when recovering volumes. This skips checking your recovery destination disks for bad cluster information. If you are restoring to an alternate server or hardware, this switch should not be used. You can manually run the command chkdsk /b on your recovery disks at any time to check them for bad clusters, and then update the file system information accordingly
-userSpecifies the user name with write access to the backup destination (if it is a shared network folder). The user needs to be a member of the Administrators or Backup Operators group on this computer.
-quietRuns the command with no prompts to the user.
-versionSpecifies the version of the backup in MM/DD/YYYY-HH:MM format, as listed by wbadmin get versions.
-vssFullIf specified, performs a full backup using Volume Shadow Copy Service (VSS). Each file’s history is updated to reflect that it was backed up.

If this parameter is not specified, Start Backup makes a copy backup, but the history of files being backed up is not updated.

Caution: Do not use this parameter when using a non-Microsoft program to back up applications.

2.1. Wbadmin Enable Backup

The following subcommand enables or configures scheduled daily backup:

Wbadmin enable backup
[-addtarget:{backuptargetdisk | backuptargetnetworkshare}]
[-removetarget:{backuptargetdisk | backuptargetnetworkshare}]
[-schedule:timetorunbackup]
[-include:volumestoinclude]
[-allcritical]
[-user:username]
[-password:password]
[-inheritacl:inheritacl]
[-quiet]

2.2. Wbadmin disable backup

The following subcommand disables running scheduled daily backups:

wbadmin disable backup
[-quiet]

2.3. Wbadmin start backup

The following subcommand runs a backup job:

wbadmin start backup
[-backupTarget:{TargetVolume | TargetNetworkShare}]
[-include:VolumesToInclude]
[-allCritical]
[-vssFull]
[-noVerify]
[-user:UserName]
[-password:Password]
[-noinheritAcl]
 [-quiet]

2.4. Wbadmin stop job

The following subcommand stops a running backup or recovery job:

Wbadmin stop job
[-quiet]

2.5. Wbadmin start recovery

The following subcommand runs a recovery based on the specified parameters:

wbadmin start recovery
-version:VersionIdentifier
-items:VolumesToRecover | AppsToRecover | FilesOrFoldersToRecover}
-itemtype:{Volume | App | File}
[-backupTarget:{VolumeHostingBackup | NetworkShareHostingBackup}]
[-machine:BackupMachineName]
[-recoveryTarget:{TargetVolumeForRecovery | TargetPathForRecovery}]
[-recursive]
[-overwrite:{Overwrite | CreateCopy | Skip}]
[-notRestoreAcl]
[-skipBadClusterCheck]
[-noRollForward]
[-quiet]

2.6. Wbadmin start systemstatebackup

The following subcommand creates a backup of the system state of a computer. A backup of the system state can be saved only to a locally attached disk (either internal or external). It cannot be saved to a DVD or to a remote shared folder. In addition, only the system state and system applications can be recovered from this backup—volumes and files cannot be recovered from this backup.

wbadmin start systemstatebackup
-backupTarget:<VolumeName>
[-quiet]

2.7. Wbadmin start systemstaterecovery

The following subcommand runs a system state recovery based on the supplied parameters:

wbadmin start systemstaterecovery
-version:VersionIdentifier
-showsummary
[-backupTarget:{VolumeName | NetworkSharePath}]
[-machine:BackupMachineName]
[-recoveryTarget:TargetPathForRecovery]
[-excludeSystemFiles]
[-authsysvol]
[-quiet]

2.8. Wbadmin start sysrecovery

The following subcommand runs a system recovery based on specified parameters. This command can be run only from the Windows Recovery Environment, and it is not listed by default in the usage text of Wbadmin. (You can access the Windows Recovery Environment from a Windows Server 2008 R2 installation DVD by inserting the DVD and following the steps in the wizard until you see the option Repair Your Computer. Click this link to open the System Recovery Options dialog box.)

wbadmin start sysrecovery
-version:VersionIdentifier
-backupTarget:{VolumeHostingBackup | NetworkShareHostingBackup}
[-machine:BackupMachineName]
[-restoreAllVolumes]
[-recreateDisks]
[-excludeDisks]
[-dfsAuth]
[-skipBadClusterCheck]
[-quiet]

2.9. Windows Recovery Environment

Windows Recovery Environment (Windows RE) is a recovery platform designed to automatically repair common causes of unbootable operating system installations. When the computer fails to start, Windows automatically fails over into this environment, and the Startup Repair tool in Windows RE automates diagnosis and repair. In addition, Windows RE is a starting point for various tools for manual system recovery.

Windows RE is a partial version of the operating system plus a set of tools you can use to carry out operating system or full server recoveries, using a backup that you created earlier using Windows Server Backup.

2.10. Wbadmin get versions

The following subcommand reports on the available backups:

wbadmin get versions
[-backupTarget:{VolumeName | NetworkSharePath}]
[-machine:BackupMachineName]

2.11. Wbadmin get status

The following subcommand reports the status of the current backup or recovery:

wbadmin get status
 
Others
 
- Windows 8 : Security - Securing Internet Explorer
- Windows 8 : Security - Encrypting File System
- Windows 8 : Security - BitLocker Drive Encryption
- Windows Vista : Deployment Platform - Basic Deployment Process, BDD 2007 Deployment Process
- Windows Vista : Platform Components (part 2) - Windows Setup, Sysprep, Windows PE, Windows DS, ImageX
- Windows Vista : Platform Components (part 1) - Windows Imaging, Answer Files, Windows SIM
- Windows 7 : Using the Default Programs Page (part 2) - Change AutoPlay settings, Set program access and computer defaults
- Windows 7 : Using the Default Programs Page (part 1) - Set your default programs, Associate a file type or protocol with a specific program
- Windows 7 : Setting Default Programs for Files
- Windows 7 : Editing the Registry - Backing Up and Restoring the Registry
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us