PowerShell Script – Veeam – Download Monthly Backup from SBOR Capacity Tier for selected VM

In Veeam backup management, it is supported to offload the GFS backup copy from performance tier repository to capacity tier repository. Normally the capaticyt tier will be configured on object storage (Azure Blob, AWS S3 and etc.) to reduce the storage cost.

However, when retrieve(download) the backup from capacity tier repository, there is only one option to download the backup for entire backup job which mighy includes multiple virtual machines. This short powershell script is crafted to download the monthly GFS bakcup for selected VM.

#This is the powershell script to download the select Veeam GFS Monthly backup from SOBR Capacity Tier.
#
#The csv file format:  
#     columns vmname,copyjobname
#
#Install Veeam Powershell Module via https://helpcenter.veeam.com/docs/backup/powershell/using_get-vbrcommand.html?ver=110

param
(
   [alias("i")]
   [string]$inputfile = $(read-host -Prompt "Enter the full path to the list of the CSV input file")
)

#Prepare Log File
$TimeStamp1 = $(((get-date).ToUniversalTime()).ToString("yyyyMMddTHHmmssZ"))
$output1 = "d:\temp\testlogfile$TimeStamp1.txt"
New-Item -Path $output1 -ItemType File > $null

Import-Csv $inputfile | foreach {
             
        $backup1 = Get-VBRBackup -name $_.copyjobname
        $backupfiles1 = Get-VBRBackupFile -Backup $backup1
        
        $filename1 = $_.vmname+".*_M.vbk"  #Select GFS Monthly backup
        $totalfile1 = $backupfiles1.count - 1
        $downloadcounter = 0

        $msg0 = "Start to download Monthly Backup File start with "+ [string]$_.vmname
        Add-content $output1 -value "---------------------------------------------"
        Add-content $output1 -value $msg0
        Add-content $output1 -value "---------------------------------------------"
        
        For ($i=0; $i -le $totalfile1; $i++) {
                    
            if ($backupfiles1[$i].path.ToString() -like $filename1)   {
                           
                if ($backupfiles1[$i].IsAvailable.ToString() -eq "True") {

                        $downloadcounter++
                        $msg1 =  [string]$downloadcounter+"."+$backupfiles1[$i].path.ToString()+"--Start to download "                                                                
                        Add-content $output1 -value $msg1
                        
                        $job1 = Start-VBRDownloadBackupFile -BackupFile $backupfiles1[$i] -ThisBackupAndIncrements
                        
                        $msg2 =  [string]$downloadcounter+"."+$backupfiles1[$i].path.ToString()+"--Completed downloading with job id "+[string]$job1                    
                        Add-content $output1 -value $msg2
                                    
                }
            
            }

        }
        
        Add-content $output1 -value "Download Completed. Total $downloadcounter files downloaded"

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s