Full server backup using powershell script

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

#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


July 31st, 2015 7:34pm

You can ask the author by posting your question on the Q&A tab:

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

Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 8:31pm

Change this line:

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

To this:

#List critical volumes
$Volumes
= Get-WBVolume -CriticalVolumes

See: https://technet.microsoft.com/en-us/library/Ee706679.aspx





July 31st, 2015 9:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics