Question

nas backup recovery file via powershell script


Userlevel 1

Hello everyone
I am trying to restore files in a specific path from the current backup restore point.
The number of files to be restored is large and scattered, so it is done using a powershell script.
The backup image is that of the NAS server.
The command used is Save-VBRNASBackupFLRItem.
However, when recovering through the command below, if the type is a folder, only the entire folder is restored.
However, I want to select and recover only some files, not all files in the folder.
What should I do?

## Powershell script (test environment)
$nfs_source = Get-VBRNASServer | Where-Object {$_.path -eq "nas:/nfs"}
$nfs_restore = Get-VBRNASServer | Where-Object {$_.path -eq "nas:/restore"}
$path_restore = Get-VBRNASServerPath -Server $nfs_restore
$restorepoint_nfs=Get-VBRNASBackupRestorePoint | Where-Object {$_.NASServerName -eq "nas:/nfs" -and $_.CreationTime.tostring() -eq "5/25/2023 11:47:43 AM"}
$restore_session_nfs = Start-VBRNASBackupFLRSession -RestorePoint $restorepoint_nfs

$list_files = Get-VBRNASBackupFLRItem -Session $restore_session_nfs
Save-VBRNASBackupFLRItem -Item $list_files[0] -Server $nfs_restore -Path $($path_restore+"/test") -PreservePermissions:$true
Stop-VBRNASBackupFLRSession -Sessio $restore_session_nfs

 

$list_files is as below
PS C:\test> $list_files


Type : Folder
CreationDate: 2023-05-25 10:19:22 AM
Path : file1
Name: file1

Parent:
ModificationDate : 2023-05-25 10:19:22 AM
VersionId : 4

Size : 450733505
Type : File
CreationDate: 2/28/2023 11:45:06 AM
Path : bandicam 2023-02-28 09-32-01-032.mp4
Name : bandicam 2023-02-28 09-32-01-032.mp4
Parent:
ModificationDate: 2/28/2023 11:45:06 AM
VersionId : 4

Size : 457012698
Type : File
CreationDate: 2023-02-28 4:38:07 PM
Path : bandicam 2023-02-28 14-14-16-827.mp4
Name : bandicam 2023-02-28 14-14-16-827.mp4
Parent:
ModificationDate : 2023-02-28 4:38:07 PM
VersionId : 4

Size : 457012698
Type : File
CreationDate: 2023-02-28 4:38:07 PM
Path : copy1-1.mp4
Name : copy1-1.mp4
Parent:
ModificationDate : 2023-02-28 4:38:07 PM
VersionId : 4

Size : 450733505
Type : File
CreationDate: 2/28/2023 11:45:06 AM
Path : copy2-2.mp4
Name : copy2-2.mp4
Parent:
ModificationDate: 2/28/2023 11:45:06 AM
VersionId : 4

Size : 5765996544
Type : File
CreationDate: 6/16/2017 6:05:32 PM
Path : SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_Korean_-2_MLF_X21-22833.ISO
Name : SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_Korean_-2_MLF_X21-22833.ISO
Parent:
ModificationDate : 2017-06-16 6:05:32 PM
VersionId : 4

 

Below is the file list of the test nas server. 

(top is nas:/nfs , bottom is nas:/nfs/file1)

 

Thanks for reading.


4 comments

Userlevel 7
Badge +13

Hi @jhlee ...I’m wondering if this is more of a PoSH misconfiguration than a Veeam Script Module feature lack. What I mean by this is getting files within a folder path can be tricky due to some ‘quirks’ in how it needs to be done. Though I’ve used PoSH quite a bit and feel comfortable scripting, I wouldn’t call myself an expert by any means. This being said, I have played with retrieving files & folders a bit using the Get-ChildItem cmdlet and notice some requirements from Microsoft as noted here. If you look down the page just a bit, there is a character requirement to retrieve just the files within a Folder path, and not just the whole Folder. You must use a * at the end of your Path to retrieve all the files within a Folder (i.e. C:\Path\* and not C:\Path). Can you try adding the asterisk at the end of your Path variable and see if doing so helps?

Userlevel 7
Badge +6

I agree with @coolsport00 

You will need to use a * after the folder name otherwise PowerShell will be trying trying to explicitly reference just the folder and not the level below. 

Userlevel 1

Thank for reply. I will try it and add comment

Userlevel 7
Badge +13

Great...keep us posted on how it goes. 

Comment