-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2019 9:22 pm
- Full Name: Dan Meddock
- Contact:
File Level Restore Script - Exclude System Reserved Volume
I have a script I created to run through all jobs and restore a specified file to test the backups of every VM in every job for every volume.
I'm trying to find a way to exclude the system reserve volume, but so far the best thing I could think of was to exclude Volume0 which is usually the system reserve volume. This works but I'm worried about servers that might not have that the system reserve volume. I'd rather have this setup to exclude volumes that are like 20GB or less, so it will skip the system reserve volume and any USB volumes. Maybe skipping Volume0 is the way to go in this scenario, idk. Any help would be greatly appreciated!
I'm trying to find a way to exclude the system reserve volume, but so far the best thing I could think of was to exclude Volume0 which is usually the system reserve volume. This works but I'm worried about servers that might not have that the system reserve volume. I'd rather have this setup to exclude volumes that are like 20GB or less, so it will skip the system reserve volume and any USB volumes. Maybe skipping Volume0 is the way to go in this scenario, idk. Any help would be greatly appreciated!
-
- Product Manager
- Posts: 14314
- Liked: 2890 times
- Joined: Sep 01, 2014 11:46 am
- Full Name: Hannes Kasparick
- Location: Austria
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
Hello,
and welcome to the forums.
If you have your testfile always in the same path, then I would just scan all volumes and throw an error if nothing was found for a machine. As everything is mounted to c:\veeamflr, it does not take any time to check all volumes.
Best regards,
Hannes
and welcome to the forums.
If you have your testfile always in the same path, then I would just scan all volumes and throw an error if nothing was found for a machine. As everything is mounted to c:\veeamflr, it does not take any time to check all volumes.
Best regards,
Hannes
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2019 9:22 pm
- Full Name: Dan Meddock
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
But is there a way for me to check the volumes or check the volume space or some way to exclude the system reserve volume? Currently I have it skipping Volume0 to accomplish this. But once I have to scale the script that might become and issue. So I want to find a way to check each volume. The testfile part is working just fine. I just want the script to recognize the system reserve volume and skip trying to do a FLR. So my script works fine currently just trying to future proof it a bit.
-
- Veeam Software
- Posts: 1918
- Liked: 636 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
Hi Dan,
Can you, please, share the script part where it runs for the jobs and excludes Volume0?
Thanks,
Can you, please, share the script part where it runs for the jobs and excludes Volume0?
Thanks,
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2019 9:22 pm
- Full Name: Dan Meddock
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
Code: Select all
# Script to do File Level Restore Testing for Veeam Backup jobs.
Add-PSSnapin VeeamPSSnapin
New-Eventlog -LogName Application -Source "File Restore Testing"
# Get a list of all jobs in Veeam
foreach ($job in Get-VBRJob)
{
$vms = Get-VBRJobObject -job $job.name
foreach ($vm in $vms)
{
$WFLR = Get-VBRRestorePoint -Name $vm.name | Sort CreationTime -Descending | Select -First 1 | Start-VBRWindowsFileRestore
#Split string into an array of drives
$driveArrays = $WFLR.drives -split ', '
# FLR testing report directory
$restoreDir = "C:\Special Restores\report.txt"
# Get today's date
$todaysDate = (get-date).ToString("yyyyMMdd")
#Iterate through all drives, one at a time
Foreach ($drive in $driveArrays)
{
# Splits drives string up into an array to extract Volume name and VM name
$volumeArray = $drive -split '\\'
# Get volume name
$volume = $volumeArray[3]
# Clean up VM name
$vmArray = $volumeArray[2] -split '_'
# Get VM name
$virtualMachine = $vmArray[0]
# Set file path to variable
$restoreFile = "$drive\restoretesting.txt"
# Check if file exists
$FileExists = Test-Path -LiteralPath $restoreFile
# Get date from one week ago
$lastWeek = (get-date).AddDays(-7).ToString("yyyyMMdd")
# Skips checking Volume0 since that is usually the System Reserve Partition
If($volume -notmatch 'Volume0')
{
#If it exists then restore file and log results into log file
If($FileExists -eq $True)
{
# Pull the date from the first line of the restore file
$rstFileDate = Get-Content -Path $restoreFile -TotalCount 1
# Verify the restore file date and ensure its within the past week
If($rstFileDate -gt $lastWeek)
{
$eventType = "Information"
copy-item -path $restoreFile -destination "C:\Special Restores\restoreFile-$virtualMachine-$todaysDate.txt"
$testLog = "[$(Get-Date -format 'u')] [SUCCESS] [$virtualMachine] $volume - Restore file is current and testing completed successfully"
}
# If the file exists but the first line containing the date is older than a week; throw warning
Else
{
$eventType = "Warning"
copy-item -path $restoreFile -destination "C:\Special Restores\restoreFile-$virtualMachine-OUTofDATE.txt"
$testLog = "[$(Get-Date -format 'u')] [WARNING] [$virtualMachine] $volume - Restore file is out of date - ($rstFileDate)"
}
}
# File doesn't Exist in specified directory
Else
{
$eventType = "Error"
$testLog = "[$(Get-Date -format 'u')] [FAILED] [$virtualMachine] $volume is missing $restoreFile"
}
# Write results to log file and append post results
Add-Content -Path $restoreDir -Value $testLog
# Write results to event log
Write-EventLog -LogName Application -Source "File Restore Testing" -EntryType $eventType -EventId 6969 -Message $testLog
}
}
#End the file level restore
Stop-VBRWindowsFileRestore $WFLR
}
}
-
- Veeam Software
- Posts: 1918
- Liked: 636 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
Hi Dan,
I would say, you can verify if a particular file, which actually belongs inside "system reserve partition" volume, exists on every drive you are parsing through
and then treat the drive accordingly.
Have a try playing around with the line:
I took BOOTSECT.BAK as a part of System Reserved Partition volume as an example. (guess, you can also specify Boot folder, bootmgr file and etc.).
As per your code:
All the best,
Oleg
I would say, you can verify if a particular file, which actually belongs inside "system reserve partition" volume, exists on every drive you are parsing through
and then treat the drive accordingly.
Have a try playing around with the line:
Code: Select all
test-path -path ($drive + '\BOOTSECT.BAK')
As per your code:
Code: Select all
foreach ($vm in $vms)
{
$WFLR = Get-VBRRestorePoint -Name $vm.name | Sort CreationTime -Descending | Select -First 1 | Start-VBRWindowsFileRestore
#Split string into an array of drives
$driveArrays = $WFLR.drives -split ', '
# FLR testing report directory
$restoreDir = "C:\Special Restores\report.txt"
# Get today's date
$todaysDate = (get-date).ToString("yyyyMMdd")
#Iterate through all drives, one at a time
Foreach ($drive in $driveArrays)
{
# Splits drives string up into an array to extract Volume name and VM name
$volumeArray = $drive -split '\\'
# Get volume name
$volume = $volumeArray[3]
# Clean up VM name
$vmArray = $volumeArray[2] -split '_'
# Get VM name
$virtualMachine = $vmArray[0]
=====================================================================
# Test if the system file exists within a parsed volume
$systemDrive = test-path -path ($drive + '\BOOTSECT.BAK')
=====================================================================
# Set file path to variable
$restoreFile = "$drive\restoretesting.txt"
# Check if file exists
$FileExists = Test-Path -LiteralPath $restoreFile
# Get date from one week ago
$lastWeek = (get-date).AddDays(-7).ToString("yyyyMMdd")
==========================================================================================
# Continue checking if the drive doesn't contain the System Reserve Partition drive file.
If($systemDrive -eq $False)
{
##Restoration actions
}
==========================================================================================
Oleg
-
- Novice
- Posts: 4
- Liked: never
- Joined: Oct 07, 2019 9:22 pm
- Full Name: Dan Meddock
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
If I can just check if the volume size is less than say 15GB, it would skip the volume. I just cant figure out how to pull that information.
-
- Veeam Software
- Posts: 1918
- Liked: 636 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: File Level Restore Script - Exclude System Reserved Volume
I don't see it as a way to go since volumes are not being physically extracted to a Mount Server under 'C:\VeeamFLR', but mounted. Thus, Windows File Explorer treats Volume0, Volume1 etc. as symbolic links to the folders (volumes) rather than the folders themselves.
So, parsing their sizes in the way, which would normally work, doesn't resolve the case:
Hence, I would recommend testing if a particular "boot" file exists in every drive as an easier method.
So, parsing their sizes in the way, which would normally work, doesn't resolve the case:
Code: Select all
PS C:\VeeamFLR> $fso = New-Object -ComObject "Scripting.FileSystemObject"
>> $drives = get-childitem -path "C:\VeeamFLR\Macchina-WD10-01_d73d6708" -directory -recurse -Depth 0 |
>> foreach {
>> $size = ($fso.GetFolder("$($PSItem.FullName)")).Size
>> $folder = @{ Name = $PSItem.Name; SizeMB = [math]::Round( ($size / 1mb), 2)}
>> write-host $folder.Name 'has' $folder.SizeMB 'mb'
>> }
Volume0 has 0 mb
Volume1 has 0 mb
PS C:\VeeamFLR>
Who is online
Users browsing this forum: No registered users and 15 guests