PowerShell script exchange
Post Reply
RWeiss
Enthusiast
Posts: 28
Liked: 1 time
Joined: Nov 13, 2014 10:29 am
Contact:

File to Tape -> Add SMB Share

Post by RWeiss »

Hello

We have a File to Tape job that has an SMB share as target. The SMB Share has been added to the inventory and I can select the SMB share in the File to Tape job and select an appropriate path I want to backup. We have setup such a job including a file filter which runs without any issue.

What we need to do is, however, to change the file filter with every run, as the job only needs to target specific files which are named after a specific day. Again, no issue to do this manually but we want to automate this of course.
I was happy to see that everything that I would need is available in the Powershell cmdlet.

- Set-VBRFileToTapeJob ( https://helpcenter.veeam.com/docs/backu ... ml?ver=100 )
- VBRFileToTapeJob ( https://helpcenter.veeam.com/docs/backu ... ml?ver=100 )
- New-VBRFileToTapeObject ( https://helpcenter.veeam.com/docs/backu ... ml?ver=100 )
- VBRFileToTapeObject ( https://helpcenter.veeam.com/docs/backu ... ml?ver=100 )

I would create a new VBRFileToTapeObject with the Server specified (Get-VBRServer).
THe problem is, however, that I am unable to add a path formatted as an UNC path. I can do this without an issue when I add a folder manually to the job and when I query this job I can clearly see that the path string is a normal UNC path but it seems that the cmdlet does not accept UNC paths as an argument?
I assume it does not work because I need to specify a NASServer instead of a Server, as described in the documentation. However, my cmdlet does not seem to recognize the -NASServer parameter? I'm on version 10 P2.

jhoughes
Veeam Software
Posts: 190
Liked: 60 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: File to Tape -> Add SMB Share

Post by jhoughes »

Please post your code to be able to assist, but I'd suspect that you are eihter mixing parameters from both sets, or you are not using the 'Get-VBRNASServer' cmdlet to return the correct object type for the 'NASServer' parameter.

Below is sample code pulled from existing scripts for creating an NASSMBServer targeting a UNC path, along with creating a file to tape job for that object. This should get you started.

Code: Select all

#Create NAS Proxy, NAS Server, NAS Object & NAS job
$RepositoryName = 'ReFS-PerVM'
$Repository = Get-VBRBackupRepository -Name $RepositoryName

$ProxyServer = Get-VBRServer -Name 'ausveeampxy02.lab.fullstackgeek.net'
$VBRNASProxyServer = Add-VBRNASProxyServer -Server $ProxyServer -Description 'Demo File Proxy'

$NASCredentials = Get-Credential -Username 'admin' -Message 'NAS Admin Credentials'
$NASServer = Add-VBRNASSMBServer -Path '\\192.168.50.9\LabMedia' -AccessCredentials $NASCredentials -CacheRepository $Repository -ProcessingMode Direct -ProxyMode SelectedProxy -SelectedProxyServer $VBRNASProxyServer -BackupIOControlLevel Medium

#Create File to tape object & job
[string]$IncludeMask = '*.*'
[string]$ExcludeMask = ''

#If NASServer was not saved in a variable, you can get it by ID.
#$NASServer = Get-VBRNASServer -Id '055d56fb-2b37-4032-b3b4-364140ea4578'

$FileToTapeObject = New-VBRFileToTapeObject -NASServer $NASServer
$MediaPool = Get-VBRTapeMediaPool -Name 'MediaPool2'
$MonthlyOptions = New-VBRMonthlyOptions -DayNumberInMonth Last -DayOfWeek Saturday -Period 04:00
$FullBackupPolicy = New-VBRFileToTapeBackupPolicy -Type Monthly -MonthlyOptions $MonthlyOptions -Enabled
Add-VBRFileToTapeJob -Name 'ScriptedFileToTapeNAS' -Description 'PowerShell Testing' -Object $FileToTapeObject -FullBackupMediaPool $MediaPool -FullBackupPolicy $FullBackupPolicy
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMUG US South Regional Champion | VMware vExpert | Cisco Champion

RWeiss
Enthusiast
Posts: 28
Liked: 1 time
Joined: Nov 13, 2014 10:29 am
Contact:

Re: File to Tape -> Add SMB Share

Post by RWeiss »

Thank you.

Yes, I figured that out based on the example - the definitions below are a bit confusing though as it states Path is required (which is only the case if used in conjunction with servers and not with NASServers).

That's clear now! Note to self: read syntax examples first :)

However, I am still a bit confused regarding the reason why I cannot choose a path. I would ideally like to have the NAS Server / SMB Share added to Veeam representing the base directory of the share. In the job itself, I want to define various sub-directories of this NAS Server - which is possible when I do that manually.
However, as I am not allowed to specify a path together with the NASServer using the cmdlet, I will need to add each folder I want to backup individually as a NASServer first? Or am I still missing something?

jhoughes
Veeam Software
Posts: 190
Liked: 60 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: File to Tape -> Add SMB Share

Post by jhoughes »

Yes, the Path and NASServer cmdlets are in different parameter sets, they cannot be used together.

Since you want to handle multiple folders, or may be easier to map your share to the managed server and use the local drive letter to be able to specify path. I’ve not tested that, but I believe it should work.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMUG US South Regional Champion | VMware vExpert | Cisco Champion

RWeiss
Enthusiast
Posts: 28
Liked: 1 time
Joined: Nov 13, 2014 10:29 am
Contact:

Re: File to Tape -> Add SMB Share

Post by RWeiss »

Ok then that's a bit of a feature mismatch between the powershell cmdlet and what's possible in the Veeam Console. Hopefully this can be added in the future, as I would like to add SMB shares and then select subfolders in these shares for certain jobs, the same way I can in the console.
In this case, it's sadly no machine I can add as a managed server, so for now really need to add each subfolder as a separate SMB share if I want to modify the sets in Powershell.

Thank you for the help though - I got it working now and added the script to run before the job. Works flawlessly :)

oleg.feoktistov
Veeam Software
Posts: 406
Liked: 130 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: File to Tape -> Add SMB Share

Post by oleg.feoktistov »

As soon as you add SMB share to your VBR console, on the backend it is also added as CHost object of CifsServer type retrievable with Get-VBRServer. And if SMB share is hosted on regular Linux or Windows machine, you can then specify its local path and create FileToTapeObject normally:

Code: Select all

$server = Get-VBRServer | where {$_.Type -eq 'CifsServer'}
$path = 'C:\Temp'
$object = New-VBRFileToTapeObject -Server $server -Path $path
Cheers!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests