Wondering how to create an offline disk back-up copy with more than one USB Disk? And not want to spend your IT budget on “Veeam cloud connect” This is originally not possible with the Veeam GUI because you can’t map 1 backup copy job against 2 USB disks. The job will fail because Veeam cant find one incremental which one is copied on the second USB disk which is on a safe place @home. I made a script for enabling and disabling the right copy job for each mapped USB disk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
<# .SYNOPSIS Veeam offline copy to USB or other External disk. .DESCRIPTION PRE-REQUIREMENT!!: 1 or more usb or external disks. Created repositories and Backup copy jobs in Veeam. This scripts contains 3 Functions 1. Prepare offline media for copying to it. 2. Enable and Disable Veeam jobs. 3. Write logging to file .PARAMETER(s) $DiskId = The diskid which is given in the get partition CMDLet or gui. $TargetDrvLtr = Driveletter where the Veeam repository is mapped to $USBDisklabels = Volumenames $BCopyJob = Backupcopyjobnames $Logfile = Logging the actions to a logfile .INPUTS $PartitionInfo = PartitionStuff -DiskId "usb" -TargetDrvLtr "Z" TheVeeamStuff -PartitionInfo $PartitionInfo -UsbDiskLabel1 "USBDISKLABEL1" -UsbDiskLabel2 "USBDISKLABEL2" -BCopyJob1 "BCOPY1" -BCopyJob2 "BCOPY2" -logfile "C:\PSScripts\VBRTaskLogging.txt" .OUTPUTS Log file stored in C:\.log> .NOTES Version: 1.0 Author: Rob Verhees Creation Date: 13-12-2018 Purpose/Change: Initial script development #> Function PartitionStuff { Param( $DiskId, $TargetDrvLtr ) $drvltr = get-partition | where{$_.DiskId -match $DiskId} IF(!$drvltr){ write-log -Level ERROR -logfile $logfile -Message "Cant find disk with DiskID $($diskid)" } IF($drvltr.DriveLetter -ne $TargetDrvLtr ){ $drvltr | Set-Partition -NewDriveLetter $TargetDrvLtr } Else { write-log -Level INFO -logfile $logfile -Message "TargetDriveletter already present!" } IF($drvltr){ $PartitionInfo = $drvltr | get-volume | select -ExpandProperty filesystemlabel } $PartitionInfo } function LoadVeeamPowerShell { Try { Add-PSSnapin VeeamPSSnapin } Catch { write-log -Level ERROR -logfile $logfile -Message "Cant load Veeam!" Exit } Try { get-vbrserver } Catch { write-log -Level ERROR -logfile $logfile -Message "Change the permissions of the following registry key: \\HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication\ -> Users full control." write-log -Level ERROR -logfile $logfile -Message ":: Or run this Script as Administator, not recommended when using a scheduled task." Exit } } function TheVeeamStuff { Param ( $PartitionInfo, $UsbDiskLabel1, $UsbDiskLabel2, $BCopyJob1, $BCopyJob2, $logfile ) LoadVeeamPowerShell IF($PartitionInfo -match $UsbDiskLabel1){ Try { Get-VBRBackupRepository -Name $UsbDiskLabel1 | Sync-VBRBackupRepository write-log -Level INFO -logfile $logfile -Message "Syncing repository $($usbdisklabel1)" start-sleep -Seconds 60 Get-VBRJob | where{$_.name -eq $BCopyJob1} | Enable-VBRJob write-log -Level INFO -logfile $logfile -Message ":: Enabling VBRJob $($BCopyJob1)" Get-vbrjob | where{$_.name -eq $BCopyJob2} | Disable-VBRJob write-log -Level INFO -logfile $logfile -Message ":: Disabling VBRJob $($BCopyJob2)" } Catch { write-log -Level ERROR -logfile $logfile -Message "Can't find VBRjob or Repository" write-log -Level ERROR -logfile $logfile -Message ": Errormessage: $($_.exception.message)" Exit } } ELSEIF($PartitionInfo -match $UsbDiskLabel2) { Try { Get-VBRBackupRepository -Name $UsbDiskLabel2 | Sync-VBRBackupRepository write-log -Level INFO -logfile $logfile -Message "Syncing repository $($usbdisklabel2)" start-sleep -Seconds 60 Get-VBRJob | where{$_.name -eq $BCopyJob2} | Enable-VBRJob write-log -Level INFO -logfile $logfile -Message ":: Enabling VBRJob $($BCopyJob2)" Get-vbrjob | where{$_.name -eq $BCopyJob1} | Disable-VBRJob write-log -Level INFO -logfile $logfile -Message ":: Disabling VBRJob $($BCopyJob1)" } Catch { write-log -Level ERROR -logfile $logfile -Message "Can't find VBRjob or Repository" write-log -Level ERROR -logfile $logfile -Message ": Errormessage: $($_.exception.message)" } } Else { write-log -Level ERROR -logfile $logfile -Message "$($Partitioninfo) and the given External disk label does not match each-other." } } Function Write-Log { [CmdletBinding()] Param( [Parameter(Mandatory=$False)] [ValidateSet("INFO","WARN","ERROR","FATAL","DEBUG")] [String] $Level = "INFO", [Parameter(Mandatory=$True)] [string] $Message, [Parameter(Mandatory=$False)] [string] $logfile ) $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") $Line = "$Stamp $Level $Message" If($logfile) { if (!(Test-Path $logfile)) { New-Item -path $logfile -type "file" } Add-Content $logfile -Value $Line } Else { Write-Output $Line } } $PartitionInfo = PartitionStuff -DiskId "usb" -TargetDrvLtr "Z" TheVeeamStuff -PartitionInfo $PartitionInfo -UsbDiskLabel1 "USBDISKLABEL1" -UsbDiskLabel2 "USBDISKLABEL2" -BCopyJob1 "BCOPY1" -BCopyJob2 "BCOPY2" -logfile "C:\PSScripts\VBRTaskLogging.txt" |