Auto-Update File Backup Job from DFS
Several month ago I was at a customer how has several hundreds of shares on a NetApp system and some shares on a Synology. This shares were mounted to a Microsoft DFS structure. For using Remote VSS it was necessary to add the originating share to the Veeam Backup & Replication Inventory. Next problem was that the number of shares has a high dynamic. They automatically create shares, delete shares or move shares somewhere else in this DFS structure.
So they needed a solution to automatically add or remove shares in File Backup Jobs. In my lab I’ve created a DFS file structure and started to build a script to do this and I learned really much about Powershell with this. Several month later (last week) customer came back to me after they purchased our solution and asked if I can assist to configure my script. While configuring this script we figured out that it needs some more enhancements like for example excluding the shares of the Synology. So I went back to my lab and created an enhanced version of this script.
After working a while on this 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.
- Update the File Backup Job to include all found shares
This an example how you can call the script:
Add-DFSTargetToNASBackupJob.ps1 -DfsRoot "\\homelab\dfs" -ScanDepth 2 -VBRJobName "NAS DFS Test" -ShareCredential "HOMELAB\Administrator" -CacheRepository "Default Backup Repository" -VolumeProcessingMode VSSSnapshot -ExcludeSystems "*lab-dc01*","*lab-nacifs01*"
The script is called with several options, which I want to explain.
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.
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.
Because the customer needs to update an existing backup job every day, we need to specify here the name of this File Backup Job. To use this script you need to create the job before the first run of this script.
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.
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.
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.
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
By default the scripts creates a log file with the name “dfsresolver4nasbackup.log” in the %ProgramData% path, but you can customize it to whatever you want.
The most current version of my script example is availible at https://github.com/marcohorstmann/powershell/tree/master/BR-NASBackup4DFS