PowerShell script exchange
Post Reply
wgoodall
Enthusiast
Posts: 28
Liked: never
Joined: Aug 30, 2022 6:21 am
Full Name: Wesley Goodall
Contact:

Powershell script to restore a file from an agent

Post by wgoodall »

Hi All,

Does anyone have any experience with scripting a file level restore of a VM or Devices, but for Agents?

I already have a script for normal Veeam Fieel Level restore jobs but it won't work with agents.

Any help would be much appreciated

Kindest Regards

Wes
HannesK
Product Manager
Posts: 14844
Liked: 3086 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Powershell script to restore a file from an agent

Post by HannesK »

Hello,
just to clarify... is it about standalone agents (without Veeam Backup & Replication), or are the backups all managed by a backup server, so you need a PowerShell script for Veeam Backup & Replication?

Best regards,
Hannes

PS: I moved your question to the PowerShell forum
wgoodall
Enthusiast
Posts: 28
Liked: never
Joined: Aug 30, 2022 6:21 am
Full Name: Wesley Goodall
Contact:

Re: Powershell script to restore a file from an agent

Post by wgoodall »

Thanks for the reply and moving to correct forum.

Yes backups are managed by Veeam Backup & Replication
HannesK
Product Manager
Posts: 14844
Liked: 3086 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Powershell script to restore a file from an agent

Post by HannesK »

Hello,
hmm, then a combination of the examples from here and here

worked for me

Code: Select all

$backup = Get-VBRBackup -Name "VAW-app01*"
$restorepoint = Get-VBRRestorePoint -Backup $backup -Name "App-01.lab.intern"
$session = Start-VBRWindowsFileRestore -RestorePoint $restorepoint[1]
can you maybe share your code and the error?

Best regards,
Hannes
wgoodall
Enthusiast
Posts: 28
Liked: never
Joined: Aug 30, 2022 6:21 am
Full Name: Wesley Goodall
Contact:

Re: Powershell script to restore a file from an agent

Post by wgoodall »

@HannesK

I'm currently doing the restore test by VMname , hence the complication for agents.

How would I change this to be used for agents .. I can see you are loading the job, then getting the restore point .. this actually looks like a cleaner method than what I am currently doing.

Script i'm using

Code: Select all

CreationTime -Descending | where {$_.VMName -eq "$vmName"} | select -First 1
$restore = $result | Start-VBRWindowsFileRestore



# Copies the Files
foreach ($file in $originalFiles) {
    
    # Find the FLR mount point for the specific drive letter
    $flrmountpoint = ($restore.MountSession.MountedDevices | ? {$_.DriveLetter -eq (Split-Path $file -Qualifier)}).MountPoint

    # Build the path to the file via the FLR mount point
    $file = $flrmountpoint + (Split-Path $file -NoQualifier)

    #Copy/Restore the files
    Copy-Item $file $destPath -Force -recurse
    }

# Stop the FLR process
Stop-VBRWindowsFileRestore  $restore
Thanks for your help

Wes
HannesK
Product Manager
Posts: 14844
Liked: 3086 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Powershell script to restore a file from an agent

Post by HannesK »

the first lines have to be changed to select the machine. "App-01.lab.intern" is the hostname, in my case, so that should help to understand the code I pasted.
wgoodall
Enthusiast
Posts: 28
Liked: never
Joined: Aug 30, 2022 6:21 am
Full Name: Wesley Goodall
Contact:

Re: Powershell script to restore a file from an agent

Post by wgoodall »

I don't follow is it possible for you can show me where to change the code?

I did change host but think i'm missing soemthing?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script to restore a file from an agent

Post by oleg.feoktistov »

Hi Wesley,

What happens if you run the code below with the actual backup and host names?

Code: Select all

$backup = Get-VBRBackup -Name "BackupName"
$restorepoint = Get-VBRRestorePoint -Backup $backup -Name "hostName"
$restorepoint
Do you get any output with a restore point?

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests