Backing up vSAN File Shares

June 18, 2021

Data is increasingly recognized as the most important asset of a business. As the amount of unstructured data steadily increases, management and protection can be a complex and costly process. vSAN native file services simplify unstructured file-based data management with support for SMB and NFS. vSAN 7 U2 extends its file service capabilities including support for stretched clusters, data-in-transit encryption, snapshots, and improved scale, performance, and efficiency.

At the time of this post, backup vendors are working to support vSAN file share snapshots as a backup source to enhance their backup and restore capabilities. Until then, customers can either configure backup jobs to use the vSAN file share as the source or use custom scripts to programmatically create and present snapshots as the source. This post will explore these options for protecting and restoring vSAN file shares.

Backing up from a vSAN File Share

One option for backing up vSAN file shares is to configure the NFS\SMB file share as the backup source and let the backup software pull the files to the designated backup repository.

Backing up directly from a vSAN file share

Backup vendors today offer powerful NAS data protection and recovery solutions that greatly reduce storage costs and improve recovery times. As an example, Veeam Backup and Replication offers Change File Tracking which maintains the footprint of the source file share, keeping track of all objects that have changed between each backup. Differential backups result in space-efficient and ultra-fast backup job processing.

One of the key considerations with this approach is that locked files will be skipped. Some backup software vendors will retry the skipped files before finishing the job, but if the file is still locked, the file will ultimately be skipped. There is also the potential for performance impact as the backup job will generate IO on the production file share.

Backing up from vSAN File Services Snapshots

While using file shares as the backup source is a common practice, there are several advantages to using snapshots as the backup source instead.

  • Avoid File Locks: File locking mechanisms can prevent write and read operations to open files which can interfere with the backup job, causing the file to be skipped. If the backup target is a snapshot, this is completely avoided.
  • Point-in-time: Point-in-time snapshots are useful when a user wants to select an exact point in time to either rollback to, or restore to an alternate location (.i.e. a testing environment) 
  • Offload: Backing up a file share can impact performance because as the files are copied to the backup repository, they are consuming IO. It is preferable to run backup jobs from a snapshot offloading the IO and reducing impact to the production workload.

These are a few of the key reasons VMware now offers support for vSAN Distributed File System (VDFS) snapshots via API. Backup vendors are currently working to support the use of VDFS snapshots as a backup source. Until then, organizations wanting to utilize VDFS snapshots today have a few options:

Manually managing VDFS Snapshots

vSAN File Services has a built-in feature that allows you to create a read-only snapshot of a vSAN file share. When the vSAN File Service is enabled, you can create up to 32 point-in-time snapshots per share. They can be created and deleted from the vCenter UI, and managed by browsing to a hidden folder in the file share path. (\\file-share-path\.vdfs\snapshot).

In the illustration below, a snapshot of the file share Profiles was created and named “veeam-backup-061721-1009”.

Manually create a vSAN file services snapshot in the vCenter UI

In the backup software, the path to the snapshot was added to the advanced properties of the file share. Now, any backup job that protects the Profiles share will know to use this snapshot as the backup source.

Using VDFS snapshot as the source for file share backup

Manually creating a snapshot and configuring it as the backup source is technically possible, but it's not scalable. For scheduled backups, there needs to be a new snapshot created before each backup interval.

While backup vendors work to incorporate the logic to generate snapshots and use them as the source for backup, this can be achieved today using PowerShell and PowerCLI.

vSAN File Service Snapshot Management with PowerCLI

Recently PowerCLI 12.3 announced support for vSAN file service snapshot management. There are 3 new cmdlets below that can be used to manage VDFS snapshots. These cmdlets can be used to create and present VDFS snapshots as a backup source. The snapshot script can be invoked as a pre-job task to ensure that every backup job creates a new snapshot and uses it as the source for the backup.

New-VsanFileShareSnapshot

This cmdlet creates a vSAN file share snapshot for the specified vSAN file share.

1 #Creates a new vSAN File Share Snapshot
2 PS C:\> New-VsanFileShareSnapshot -Name "FileShareSnapshot1" -FileShare $fileShare

Get-VsanFileShareSnapshot

This cmdlet retrieves vSAN file share snapshots based on name or other filters.

1 #Retrieves all vSAN File Share Snapshots
2 PS C:\> Get-VsanFileShareSnapshot

Remove-VsanFileShareSnapshot

This cmdlet removes vSAN file share snapshot.

1 #Removes vSAN File Share Snapshot
2 PS C:\> Remove-VsanFileShareSnapshot -FileShareSnapshot $vSanSnapshot -Confirm:$false

Example Scenario: Use VDFS snapshot as a source for backing up a file share

Objective: An administrator creates a vSAN file share named Profiles. Using Veeam Backup and Replication, they want to take daily space-efficient backups of the file share with minimal impact on production and point-in-time recovery options. 

This objective can be achieved using PowerShell and PowerCLI cmdlets.

Step 1: Using Veeam Backup and Recovery v11 the following tasks are accomplished:

  • Under Inventory, create a new NFS or SMB file share named Profiles using the file share path attained from vSAN.
  • Create a backup job and specify the path to the Profiles share.
  • Schedule the job to run on the desired interval.

Step 2: Create a PowerShell script that accomplishes the following:

1 #Snapshot Name with a Time Stamp
2 $date= Get-Date -Format "ddd_dd-MM-yyyy_HHmmss"
3 $snName = 'veeam_' + $date

4 #Create a new Snapshot
5 New-VsanFileShareSnapshot -Name $snName -FileShare $vSANFileShare -Confirm:$false
6 $SnapshotList = Get-VsanFileShareSnapshot -FileShare (Get-VsanFileShare -name profiles) 
4 #Retain the latest snapshot and delete older ones
5 $SnapshotList | Select-Object -First ($SnapshotList.Count -1) |Remove-VsanFileShareSnapshot -Confirm:$false -Verbose
6 $RecentSnapshotPath = '\\file-server.com\file-share\.vdfs\snapshot\' + $snName
7 #Update the vSAN File share SnapshotDetails using Veeam PowerShell
8 $vbServer = Get-VBRNASServer | Where-Object -FilterScript {$_.path -eq '\\file-server.com\file-share'} 
9 Set-VBRNASSMBServer -Server $vbserver -ProcessingMode StorageSnapshot -StorageSnapshotPath $RecentSnapshotPath

For the best performance experience, VMware recommends an interval of more than 1 hour between snapshots.  

Note: An example of this script can be found here. As with all sample scripts, they are meant as an example only. Use at your own risk.

Step 3: Add the script to the backup job

  • In the storage tab section of the backup job click advanced.
  • Under the Scripts tab, add the job in the “Run the following script before the job” section.

Adding snapshot script to backup job

Note: To take advantage of the new vSAN file services snapshot cmdlets, install the PowerCLI module on the backup server. Veeam’s Backup PowerShell module is installed as part of Veeam Backup and Replication.

When the backup job kicks off, the pre-job script creates a new VDFS Snapshot and identifies it as the source for the backup Job. Veeam’s Changed File Tracking maintains the footprint of the source file share and is stored in a cache repository. The cache repository keeps track of all objects that have changed between each backup, resulting in super-fast backup processing for the file share.

This is just an example of how the new vSAN file service cmdlets can potentially be used to help organizations wanting to use VDFS snapshots today, while waiting for this logic to be built into their backup software.  

Restoring vSAN File Shares

There are a number of ways to restore a vSAN file share. Be sure to check the restore options for your backup vendor. For example, Veeam Backup and Replication v11 (used in demo video) offers the following restore options:

  • Instant file share recovery: Publishes a point-in-time file share recovery as a read-only SMB file share to enable users to instantly access all protected files.
  • Restore entire share: Restores the latest version of all files to the selected location. Use this option in case of a complete loss of storage service, or major storage-level corruption impacting an unknown number of files.
  • Rollback to a point in time – Reverts all files modified since the specific date and time to the previous version, and restores all files that were deleted. Use this option to recover from ransomware, virus, or insider attack.
  • Restore individual files or folders – Restore the required file version or point-in-time state of a folder to the specified location. Use this option to find and restore missing files or folders, or fetch previous file versions.   

Demo

Conclusion

File Services in vSAN 7 Update 2 offers the ability to manage snapshots of SMB and NFS file shares. Snapshots can be managed manually in the vCenter UI or with PowerCLI cmdlets. While backup vendors work to add vSAN file share snapshots into their software, organizations can use PowerCLI today to present them as a usable backup source. The result is space-efficient point-in-time snapshots with rapid granular recovery.

Resources

Special thanks to Jatin Purohit, for his PowerShell expertise and dedication to this project. He authored the vSAN_Snapshot script used in this post. A collection of his sample scripts can found at https://github.com/jatinpurohit92.

@vPedroArrow

Filter Tags

Storage vSAN vSAN 7 Snapshots Blog Intermediate Manage

Pete Flecha

Read More from the Author

Storage & Availability Technical Marketing