PowerShell script exchange
Post Reply
iihaus
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 19, 2023 2:05 pm
Full Name: Haus Fupepe
Contact:

Powershell copy file from Linux backup to a Windows server

Post by iihaus »

I am simply trying to copy a file from a backup of a linux machine to a windows machine using Powershell. I have been following steps under the Guest OS File Recovery section of the veeam help center but getting stuck.

Here is my code so far:

Code: Select all

$backup = Get-VBRBackup -Name $BackupJobName
$restorepoint = Get-VBRRestorePoint -Backup $backup | Where-Object {$_.VMName -eq $SpecificVM} | Sort-Object creationtime -Descending | Select-Object -First 1
$server = Get-VBRServer -Name $HelperHost
$session = Start-VBRLinuxFileRestore -RestorePoint $restorepoint -MountServer $server
$items = Get-VBRLinuxGuestItem -LinuxFlrObject $session -Path "/myDir/testFile"
$targetserver = Get-VBRServer -Name $TargetWindowsMachine #comes back empty
Copy-VBRLinuxGuestItem -Item $items -LinuxFlrObject $session -TargetFolder "D:\TestFolder\" -Server $targetserver
Problems I am running into:

1) The Get-VBRServer command is not finding my $targetserver I want to copy to, even though I can find it going through a manual/GUI copy/restore.
2) If I point the $targetserver at a machine Get-VBRServer sees, I get as far as the copy piece but then get the error :Copy-VBRLinuxGuestItem : Cannot find mounted device for path: /myDir/testFile"

Does anyone have an example of or suggestions for what I am trying to accomplish? When I attempt this through the GUI I have no issues.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell copy file from Linux backup to a Windows server

Post by oleg.feoktistov »

Hi Haus,

Hard to tell right away what the issue is. In my lab the copy operation works correctly.
Suggestions/questions:

1) Try filtering out your windows host with [Veeam.Backup.Common.Core.CHost]::GetAll() and see if it's available to isolate the problem. If it's reflected with this .NET method, something's off with the cmdlet.
2) Can't reproduce it right now, but what's the source platform of your linux machine? (Hyper-V, vSphere, agent etc.)

Best regards,
Oleg
iihaus
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 19, 2023 2:05 pm
Full Name: Haus Fupepe
Contact:

Re: Powershell copy file from Linux backup to a Windows server

Post by iihaus »

Thank you for the reply Oleg,

My technical knowledge in powershell/.NET is still rather rudimentary, I'm not sure the proper usage of [Veeam.Backup.Common.Core.CHost].GetAll() ... Could you perhaps provide an example?
The source platform for the Linux machine is vSphere.

When I look at the properties for the $items variable (such as $items.creationdate) I do get the correct date, just doesn't like something about my copy :(
I have also attempted to copy to a linux machine instead of windows and still no go even though both show up when using Get-VBRServer.
ostekl1
Lurker
Posts: 1
Liked: never
Joined: Nov 10, 2016 1:13 pm
Full Name: Klaus Ostermann
Contact:

Re: Powershell copy file from Linux backup to a Windows server

Post by ostekl1 »

Hi,
is there a solution for this meanwhile?
I had the idea to do nearly exactly the same ...
Regards
Klaus
iihaus
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 19, 2023 2:05 pm
Full Name: Haus Fupepe
Contact:

Re: Powershell copy file from Linux backup to a Windows server

Post by iihaus » 1 person likes this post

It must have been something with the source machine I was working with. After changing to different source Linux box the code is now working.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests