Discussions related to exporting backups to tape and backing up directly to tape.
Post Reply
mpampuch
Lurker
Posts: 1
Liked: never
Joined: Aug 06, 2020 6:55 am
Full Name: Marco Pampuch
Contact:

File exclusion by date/size/attribute.....

Post by mpampuch »

Hello Veeam Forum,
running Veeam B&R 10 with a LTO8 Library and a few single tapedrives.
Any suggentions how to exclude files by their date/size or file attributes in a file level backup to tape job?
I already opend a ticket relating this but Veeam only supports exclusions by file names.

In my opinion a feature request. Perhaps also for agent based jobs.

In the past I used C&A ArcServe Backup for simple copy-to-tape jobs.
The filter possibilities were powerful e.g.
- dir and file masks (with wildchards, placeholder, %system variables")
- last changed / created / accessed (before, after, between)
- file size (equal, bigger, greater, between)
- file attribute (hidden, system, archive...)

Best regards,
Marco
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: File exclusion by date/size/attribute.....

Post by soncscy » 2 people like this post

Hey Marco,

Would be cool if this was built in the UI, but this is scriptable pretty easily. From working with a lot of clients that had similar requests, I learned you can add such a script as a pre-job script and the file to tape job will handle it just fine.

So you can do something like:

Code: Select all

$files2Backup = Get-ChildItem  -Recurse -Path "/path/to/root/of/your/share"
$obj = @()
Foreach($file in $files2Backup){
if($file.SomeProperty -eq "[your desired value]" -or $file.SomeOtherProperty -eq "[another value]" -or [and so on]){
$obj += $file.Path
}
$job = Get-VBRTapeJob -name 'some file to tape job'
Set-VBRFiletoTapeJob -job $job -Object $obj
This has worked out pretty well for the clients I was working with. It doesn't work so hot for Linux servers, but for managed servers it's quite clean.
johndoe10110
Influencer
Posts: 22
Liked: 5 times
Joined: Oct 23, 2013 12:49 pm
Full Name: John Dooe
Contact:

Re: File exclusion by date/size/attribute.....

Post by johndoe10110 »

Soncscy, your quick PowerShell script looks perfect for what we need. Thanks.

We have a few ad hoc files on a file share that we want to include with a 'Files to Tape' job, but the date in the filename changes each week. I take it we will have to create a post-job script to remove the files we added in the pre-job script. Correct?
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: File exclusion by date/size/attribute.....

Post by soncscy »

Hi John,

I'm very happy this helped you!

Indeed, the Set cmdlet is additive it seems (I just re-tested with v11) so you'll need a post-job script to match the same or find some way to pass the same data between sessions.

https://stackoverflow.com/questions/566 ... e-stage-to

I think this is a very simple way to do it --

1. For pre-job script, collect the Job with Get-VBRTapejob
2. The Object Property will contain the current list of files; save it to a variable
3. Do the above edits
4. Finish your pre-job script by exporting the session variables to file with export-clixml
5. Make your post-job script import the same xml; this should pass the variable between the two sessions and allow you to first overwrite the existing object data with some dummy file, then you can set the original "always to be backed up" data from the original Object Property

If your objects have just normal directories, then it's as simple as over-write and just re-add the same directories without incident.

I did re-test the process in v11, and seems that VBRFileToTapeObject is a bit more discerning now and wants paths as strings, so you'll need to first get a directory listing with Get-ChildItem -Recursive, then add path strings to the object array with $_.FullPath.ToString()

Example:

Assume we got a directory listing of $things with Get-ChildItem; initialize an array, $tobj = @(), and then:

Code: Select all

C:\Users\Administrator> foreach($thing in $things){
$obj = New-VBRFileToTapeObject -Path $thing.fullname.Tostring()
$tobj += $obj
}
$tobj can be added as a value for the -Object parameter and then set. Obviously, you can rename $things and $thing to be a bit more intelligible for your purposes.
johndoe10110
Influencer
Posts: 22
Liked: 5 times
Joined: Oct 23, 2013 12:49 pm
Full Name: John Dooe
Contact:

Re: File exclusion by date/size/attribute.....

Post by johndoe10110 »

Thanks. Yeah that does seem pretty straightforward. However, New-VBRFileToTapeObject does not seem to accept a Path in the form of a UNC. Bummer. Do you know if that is by design? It works fine if I use a path on local drives (ex: F:\Folder\SomeFile.bak).

Code: Select all

PS> New-VBRFileToTapeObject -Path "\\Server\Test\Temp\SomeFile.bak"
New-VBRFileToTapeObject : Failed to create file to tape job object. The specified parameter 'Path' is invalid: \\Server\Test\Temp\SomeFile.bak.
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: File exclusion by date/size/attribute.....

Post by soncscy »

I've not tested with SMB (to be honest i try to avoid this whenever I can), but try specifying a gateway server that has access to the share with -Server -- maybe it will work? I can test sometime later, but I'd need to actually configure an SMB share. My __guess__ is that without -Server Veeam defaults to the VBR server to try to access the share, but I don't know for sure.
johndoe10110
Influencer
Posts: 22
Liked: 5 times
Joined: Oct 23, 2013 12:49 pm
Full Name: John Dooe
Contact:

Re: File exclusion by date/size/attribute.....

Post by johndoe10110 »

No dice. Same error. It's not even getting to the part where it tries to access to the share (which it has access to).
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: File exclusion by date/size/attribute.....

Post by oleg.feoktistov » 1 person likes this post

Hi John,

Harvey's assumption is correct. When only -Path parameter is passed to New-VBRFileToTapeObject cmdlet, as a default we are trying to resolve the path specified on a local VBR server. UNC paths do not work by design, so you need to add a source server either as a managed one or as a file share. In case you want to pass it as a file share with -NASServer parameter, New-VBRFileToTapeObject will resolve and include the path specified in VBRNASServer object.

Thanks,
Oleg
enziankunz
Novice
Posts: 5
Liked: never
Joined: Sep 01, 2021 2:25 pm
Contact:

Re: File exclusion by date/size/attribute.....

Post by enziankunz »

Hi Guys
I want generate a separate VBRFileToTapeObject for each vbm and the latest vbk file in a directory of a veeam agent backup share. I'm also getting several error messages within calling "New-VBRFileToTapeObject" and trying do call it with both parameters as Oleg mentioned before (-NASServer and -Path). Unfortunately I can't get satisfaction for that :-) only erros.
What's wrong on that code? or is Oleg's advice probably obsolete in V11 or also "failure by design"? Any ideas? Really would appreciate if there are some suggestions or even better: a solution
Thx in advance for your input
E

# Setting of the backup path and the excluding directories
$b2dpath = "\\somenas.somedomain.local\B2DClients\"
$b2dnas = Get-VBRNASServer -Name "\\somenas.somedomain.local\B2DClients"
$b2tobj = @()
$b2tjob = Get-VBRTapeJob -name 'B2T Copy Veeam Agents'

# add latest vbk files from backup path to array with VBRFileToTapeObjects excluding some directories
$vbkfiles = get-childitem $b2dpath -filter "*.vbk" -rec | Where-Object {$_.FullName -notlike '*\_*' -and $_.FullName -notlike '*\@*'}
$filteredvbkfiles = $vbkfiles | group directory | foreach {@($_.group | sort {[datetime]$_.creationtime} -desc)[0]}
Foreach($file in $filteredvbkfiles){
#desperate admin: just try to concatenate a string for the relative path xyz after \\somenas.somedomain.local\B2DClients\ with or without a front trailing backslash
$str = "\"
$str += $file.DirectoryName.TrimStart($b2dpath)
#some debugging output for stupid admin of mine - myself
write-host "Server: " $b2dnas.Path "Pfad: " $str " File: " $file.Name "Directory: " $file.DirectoryName
$obj = New-VBRFileToTapeObject -NASServer $b2dnas -Path $file.Name
# also tried
#$obj = New-VBRFileToTapeObject -NASServer $b2dnas -Path $str
#$obj = New-VBRFileToTapeObject -NASServer $b2dnas -Path $str #-IncludeMask $file.Name

#add the new VBRFileToTapeObject to the array
$b2tobj += $obj
}

# add all objects to the b2t job
Set-VBRFiletoTapeJob -job $b2tjob -Object $b2tobj

# debug output
echo "Count of detected objects for copy to tape: " $b2tobj.count
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests