PowerShell script exchange
Post Reply
RWeiss
Enthusiast
Posts: 33
Liked: 2 times
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 Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
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 | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
RWeiss
Enthusiast
Posts: 33
Liked: 2 times
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 Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
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 | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
RWeiss
Enthusiast
Posts: 33
Liked: 2 times
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: 1912
Liked: 635 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!
sasilik
Expert
Posts: 104
Liked: 13 times
Joined: Jun 12, 2014 11:01 am
Full Name: Markko Meriniit
Contact:

Re: File to Tape -> Add SMB Share

Post by sasilik »

I ran into same problem after upgrading to v10. But I don't have windows or linux server hosting a share but DataDomain box. So my CifsServer is "\\dd.domain\data" now and I can't figure out local path for shares on DD box. Or can I do something like net use <drive> <datadomain share> before adding the files to the job and same for the job before it starts? Or is it not possible any more write files to tape from such devices like DD because they are NAS devices?
sasilik
Expert
Posts: 104
Liked: 13 times
Joined: Jun 12, 2014 11:01 am
Full Name: Markko Meriniit
Contact:

Re: File to Tape -> Add SMB Share

Post by sasilik »

I also can add these paths through GUI to the job and if I look at the job with Get-VBRTapeJob then all paths are there in form of array of objects named Object. If I expand array then I get objects which consist of path in form of "\\dd.domain\data\<path>" and Server property with Name \\dd.domain\data". But if I set $server to Get-VBRServer "\\dd.domain\data" and $path to "\\dd.domain\data\<path>" and do "New-VBRFileToTapeObject -Path $path -Server $server -Credentials $cred" then I get error message - Failed to create file to tape job object. The specified is invalid: \\dd.domain\data\<path>
If there is method to do it through GUI then why it can't be done through powershell?
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: File to Tape -> Add SMB Share

Post by jhoughes »

The Server and Path parameters are intended to be used for file server, as stated in the documentation for that parameter set: "Define backup servers as a source for file to tape jobs." This means that we are expecting the object fed to the Server parameter to be a managed server object (that would be returned by 'Get-VBRServer'), and that the path would be local to that server.

If you want to add file shares as objects, you need to be using the NASServer parameter, which is the other parameter set.

Sample code for that is covered earlier in the thread.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
sasilik
Expert
Posts: 104
Liked: 13 times
Joined: Jun 12, 2014 11:01 am
Full Name: Markko Meriniit
Contact:

Re: File to Tape -> Add SMB Share

Post by sasilik »

I don't need to add entire NASServer to the backup. My file to tape job consisted of multiple SMB share paths which I can add through the GUI and the result is same as it was earlier. I need to add paths under the "\\dd.domain\data" so the result is
"\\dd.domain\data\path1\path2"
"\\dd.domain\data\path3\path2"
"\\dd.domain\data\path4\path5\path6"
and so on.
As I back up files from DataDomain snapshots which have format <some path>dd-mm-yyyy-hh-mm<some other path> then if I now want to achieve same result then I must create with a script every time some 20 SMB shares, add them to tape job and after that delete them all sometime after backup. That is kind of weird way to do things.
And I still wonder, if I can browse in the GUI through this one SMB share, \\dd.domain\data, and add subfolders from there to the job then why is not that option available through powershell.
sasilik
Expert
Posts: 104
Liked: 13 times
Joined: Jun 12, 2014 11:01 am
Full Name: Markko Meriniit
Contact:

Re: File to Tape -> Add SMB Share

Post by sasilik »

I went and searched a little and using info from

https://stackoverflow.com/questions/958 ... ect-object
https://learn-powershell.net/2016/06/27 ... -property/

made corrections to my script for a workaround. I guess it is not correct way to do it and but I got it working for now and that is enough for me right now. Workaround was something like this

Code: Select all

$CIFSServer = Get-VBRNASServer -Name "\\dd.domain\data"
$Filelist_job = @()
...
$filepaths_files = @()
$filepaths_files += $DDPath + "\path1\.snapshot\db-$ReplaceStr-09-00\path2"
$filepaths_files += $DDPath + "\path3\.snapshot\db-$ReplaceStr-09-00\path4"
$filepaths_files += $DDPath + "\path5\.snapshot\db-$ReplaceStr-09-00\path6"
...
$btemp = $CIFSServer.psobject.copy()
# I got the name of the field with 
# $btemp.GetType().getfields('static,nonpublic,instance').name
# <Path>k__BackingField
# ...
$field = $btemp.GetType().getfield('<Path>k__BackingField','static,nonpublic,instance')
$filepaths_files | foreach {
    $FPath = $_
    $FPath
    $field.SetValue($btemp, $FPath)
    try {
        $NewFile = New-VBRFileToTapeObject -NASServer $btemp
    }
    catch {
        $MsgStr += $FPath + " - not found," + $CRLF
        $PathErr = 1
    }
    $Filelist_job += $NewFile
}

Set-VBRFileToTapeJob -Job $Job -Object $Filelist_job
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: File to Tape -> Add SMB Share

Post by oleg.feoktistov »

Glad you could find the workaround. Meanwhile, I noted an enhancement request for adding -Path parameter for NAS shares as well. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests