Create for every DFS target an own job

Some days ago I got a question of a customer how has more than 1300 shares and wants to have for all shares an own backup job. This shares are all in an DFS tree so the customer thought that maybe my existing script can help him, which unfortunately doesn’t work for this requirement.

In my lab I used my DFS file structure, which was created for the last script and started to modify my existing script to do this. It was quite easy to make but required a new script file.

After polish the script here are the main featues I build in this script:

  • Scan for reparse points (originating shares) in DFS
  • Exclude UNC paths on text patterns
  • Add the shares to the Veaam Backup & Replication inventory, which are not created yet.
  • Create for all new shares automatically a new backup job based on a template job.

This an example how you can call the script:

.\Add-DFSTargetsAsJobs.ps1 -DfsRoot "\\homelab\dfs" -ShareCredential "HOMELAB\Administrator" -CacheRepository "Default Backup Repository" -ScanDepth 2 -TemplateJob "Dummy NAS Job"

The script is called with several options, which I want to explain.

DfsRoot

First we need to specify which DFSRoot we want to scan. I used \\homelab\dfs as source but it will also be possible to use subfolders as well if we want to create separate jobs for different organisation structures.

ScanDepth

Because you can create a structure where reparse points are located in folders and even subfolders in the DFS root we need to scan the folder for these reparse points.

TemplateJob

In my mind a template job is better to use in such a script instead of asking for 50+ options and parameters. So just pre-create a file backup job with an test share and use the settings of this job to create a new job for every share.

ShareCredential

In this parameter you specify which credentials from Veeam Credentials Manager. This user should have backup operator permissions to bypass NTFS security to access and backup all files and folders. If the user is not used in Veeam Backup & Replication yet, you need to create it. Go to the main menu of VBR > Manage Credentials and click here on “Add” and select “Standard account…” and fill out the username and password and klick on “OK”. This username you have specified needs to be used in this parameter to select it.

CacheRepository

Veeam’s File (NAS) Backup functionality scans all shares for changes and creates fingerprints in a Cache Repository. With this parameter you specify which repository should be used for this.

VolumeProcessingMode (optional)

When adding a share to VBR you can specify if it should backup directly the share, use a VSS snapshot or another data path or often called storage snapshot. You can only use the options “Direct” and “VSSSnapshot” in this script.

ExcludeSystems (optional)

In this section you can add stringpattern which will be filtered out of all shares. If the script finds shares it will exclude all shares

LogFile (optional)

By default the scripts creates a log file with the name “Add-DFSTargetsAsJobs.log” in the %ProgramData% path, but you can customize it to whatever you want.

Download

The most current version of my script example is availible at https://github.com/marcohorstmann/powershell/blob/master/BR-NASBackup4DFS/Add-DFSTargetsAsJobs.ps1

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

10 + 15 =