0

I am using the following script from the microsoft website for create a image backup of my servers. The problem is that I have an external hard disk on one of my servers and the backup script always include the external hard disk to the image backup.

What should I have to modify in the script for make all the server without the external disk?

Source: https://gallery.technet.microsoft.com/scriptcenter/WSB-Backup-network-email-9793e315#content

OUTPUT OF Get-WBVolume -AllVolumes

VolumeLabel : System Reserved
MountPath   :
MountPoint  : \\?\Volume{e1c711f2-9b80-11e4-80b4-806e6f6e6963}
FileSystem  : NTFS
Property    : Critical, ValidSource, IsOnDiskWithCriticalVolume
FreeSpace   : 75513856
TotalSpace  : 367001600

VolumeLabel : HD2_BACKUP
MountPath   : E:
MountPoint  : \\?\Volume{ec27b343-e89b-11e4-80de-000c290bce57}
FileSystem  : NTFS
Property    : ValidSource
FreeSpace   : 754411352064
TotalSpace  : 1000202043392

VolumeLabel : SYSTEM
MountPath   : C:
MountPoint  : \\?\Volume{e1c711f3-9b80-11e4-80b4-806e6f6e6963}
FileSystem  : NTFS
Property    : Critical, ValidSource, IsOnDiskWithCriticalVolume
FreeSpace   : 77012553728
TotalSpace  : 107005083648
#requires -version 2.0 

 

#Initialize WSB cmdlets 
if ( (Get-PSSnapin -Name Windows.ServerBackup -ErrorAction SilentlyContinue) -eq $null ) 
{ 
    Add-PsSnapin Windows.ServerBackup 
} 

#------------------------------------------------------------------ 
#Variables 
#------------------------------------------------------------------  

#Files server 
$Nas = "\\FSVM001" 

#Root folder 
$HomeBkpDir = ($Nas+"\backup") 

#Backup folder 
$Filename = Get-Date -Format MMddyyyy_hhmmss 

#Number of backup to retain (value "0" disable rotation) 
$MaxBackup = 1 

#List uncritical volumes 
$Volumes = Get-WBVolume -AllVolumes | Where-Object { $_.Property -notlike "Critical*" } 

#------------------------------------------------------------------  
#Function to compare the number of folders to retain with 
#$MaxBackup (No called if $MaxBackup equals 0) 
#------------------------------------------------------------------  
function Rotation() 
{  
 #List all backup folders 
 $Backups = @(Get-ChildItem -Path $HomeBkpDir\*) 

 #Number of backups folders 
 $NbrBackups = $Backups.count 

 $i = 0 

 #Delete oldest backup folders 
 while ($NbrBackups -ge $MaxBackup) 
 { 
  $Backups[$i] | Remove-Item -Force -Recurse -Confirm:$false 
  $NbrBackups -= 1 
  $i++ 
 } 
} 

#------------------------------------------------------------------ 
#Function to send email notification 
#------------------------------------------------------------------  
function EmailNotification() 
{ 
 #Sender email 
 $Sender = "sender.at.corpnet.net" 

 #Receipt email 
 $Receipt = "receipt.at.contoso.com" 

 #SMTP Server 
 $Server = "smtp.corpnet.net" 

#Mail subject 
 $Object = $env:computername+": Backup report of "+(Get-Date) 

#Mail content 
 $Content = Get-WBJob -Previous 1 | ConvertTo-Html -As List | Out-String 

 $SMTPclient = new-object System.Net.Mail.SmtpClient $Server 

 #Specify SMTP port if needed 
 #$SMTPClient.port = 587 

 #Activate SSL if needed 
 #$SMTPclient.EnableSsl = $true 

 #Specify email account credentials if needed 
 #$SMTPAuthUsername = "login" 
 #$SMTPAuthPassword = "password" 
 #$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername, $SMTPAuthPassword) 

 $Message = new-object System.Net.Mail.MailMessage $Sender, $Receipt, $Object, $Content 
 $Message.IsBodyHtml = $true; 
 $SMTPclient.Send($Message) 
} 

#------------------------------------------------------------------ 
#Main 
#------------------------------------------------------------------  

#Execute rotation if enabled 
if ($MaxBackup -ne 0) 
{ 
 Rotation 
} 

#Backup folder creation 
New-Item ($HomeBkpDir+"\"+$Filename)  -Type Directory | Out-Null 

$WBPolicy = New-WBPolicy 

#Enable BareMetal functionnality (system state included) 
Add-WBBareMetalRecovery -Policy $WBPolicy | Out-Null 

#Add backup target 
$BackupLocation = New-WBBackupTarget -network ($HomeBkpDir+"\"+$Filename) 
Add-WBBackupTarget -Policy $WBPolicy -Target $BackupLocation -force | Out-Null 

#Add uncritical volumes 
if ($Volumes -ne $null) 
{ 
 Add-WBVolume -Policy $WBPolicy -Volume $Volumes | Out-null 
} 

$WBPolicy | Out-Null 
Start-WBBackup -Policy $WBPolicy 

#Call email notification function 
EmailNotification
  • Please can you post the output for Get-WBVolume -AllVolumes and tell us which of these volume has to be excluded ? – user2196728 Jul 31 '15 at 22:44
  • The volume E: has to be the excluded one. – ragno Aug 1 '15 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.