Microsoft Virtualization Discussions

Mount SMVI backup using Powershell?

JEFFREY_BURDZEL
5,294 Views

Hello,

I would like to be able to mount an SMVI backup from a script to our backup server in order to write that data off to tape.  Does anyone know how I can do this?  I would like to be able to do this in PowerShell, but if there is a CLI that I can install that will do this, or if there are native NetApp commands I can run from SSH, etc., that is fine with me.  I am open to any and all solutions that people may have, as I can taylor them to fit my needs!  I do have 1 question about SMVI, and that is:  Can I directly mount the snapshot from the Netapp Filer to a server and be able to browse the filesystem, or is it still encapsulated as a VMDK file?  Any info that you could pass along would be great!

Thanks in advance!

-Jeff

1 ACCEPTED SOLUTION

JEFFREY_BURDZEL
5,294 Views

I figured out how to post files 🙂  Copy these 3 files to the same directory.  These Scripts are meant to be run from the VM that you wish to mount the vmdk file to that you are backing up.  I have them setup to run as a Pre and Post command in Networker so that I can run an EOM backup to tape for a 1 year retention of the data.  The pre script will create a FlexClone from the SMVI snapshot, mount that Snapshot to each of the ESX hosts that are in the cluster of the current Vm running the script, adds the VMDK file to the VM, and then Mounts the new drive to the specified NTFS Mount folder.  The Post script will then Unmount the drive from the host, remove the .vmdk from the VM, remove the datastore from the ESX hosts in the cluster, then delete the flexclone that was created.  For extended help on running these commands, please run 'get-help .\SMVI_Mount_Pre.ps1 -Full' and 'get-help .\SMVI_Mount_Post.ps1 -Full'.  If you have any questions, comments, issues, or if you found these scripts helpful, please feel free to e-mail me at Burdzy@Gmail.com.  If there is enough interest, I can go into more detail on what exactly the script is doing, etc., and add some more comments to the scripts.  I only had a week to get them done, so I skimped on the comments to save time.

Basic examples of running the script(s):

.\SMVI_Mount_Pre.ps1 -NAFilerIP 158.228.1.2 -NAVolume SMVI_test_Volume -SMVIJobName SMVIBackup01 -VMVCenter VirtualCenter01 -VMDKPath "smvit01/smvit01_1.vmdk" -BackupMountPoint "C:\BackupMounts\smvit01\" -Pause

.\SMVI_Mount_Post.ps1 -NAFilerIP 158.228.1.2 -NAVolume SMVI_test_Volume -SMVIJobName SMVIBackup01 -VMVCenter VirtualCenter01 -VMDKPath "smvit01/smvit01_1.vmdk" -BackupMountPoint "C:\BackupMounts\smvit01\" -Pause

In these examples

158.228.1.2                                 is the IP address of the NetApp Filer

SMVI_test_Volume                    is the name of the volume on the NetApp that is being backed up

SMVIBackup01                          is the name of the Backup Job.  SMVI uses this value to name it's SnapShots

VirtualCenter01                         is the name of the Virtual Center that the Current VM Lives in.  This is needed to run the PowerCLI commands against for the datastore and VM configuration

smvit01/smvit01_1.vmdk         is the path to the actual VMDK file within the datastore that is being backed up.

C:\BackupMounts\smvit01\     is the path to the folder that you would like to mount the Drive to on the VM.

-Pause                                        is a switch that will tell the script to pause before executing each command in case you wanted to follow along and validate that each step works correctly.

VM Host Prerequisites:

  • the DataONTap powershell module MUST be installed to configure the NetApp filer
  • VMWare PowerCLI module MUST be installed to configure the Virtual Machine and ESX hosts.
  • SMVIFunctions.ps1 must be in the same folder as the scripts.
  • Please add NetApp user credentials for account that will be running the Script using the following command to prevent having to hardcode usernames/passwords inside the script
         Add-NaCredential -Controller 158.228.1.2 -Credential UserAccount
  • Run the script as an account that has Virtual Center privileges to prevent being prompted for a password for silent execution.

View solution in original post

5 REPLIES 5

datacenterdude
5,294 Views

Hi Jeff, thanks for the request!

We've just recently started an effort to create equivalent API coverage for all aspects of the NetApp VSC, including Backup & Recovery.  As these API's get created, we'll be able to make some PS cmdlets.  Though this isn't going to happen overnight, please know it's in the works, and something that a small working group of us are doing in our spare time as a sort of "community/grassroots" project.

If you check out the SMVI/VSC Install/Admin Guide, there is some 'smvicli' that you might be able to use to get done what you need.

JEFFREY_BURDZEL
5,294 Views

Thanks for the response!  I saw the SMVI CLI mentioned in a few locations, but I could never actually find a download for it.  And from what I read, the SMVICLI only works as a pre and post task to the SMVI jobs??

Anyway, I was able to write a script using a combination of VMWare's PowerCLI and NetApp's DataONTap Powershell Module to mount the backups to a folder inside of our VM as a pre-task for our backup software, and then another one to unmount the backup and clean itself up once the backup is complete.

datacenterdude
5,294 Views

Jeff,

That sounds exactly like the stuff that is driving us to further expand Powershell support by making cmdlets for VSC functionality, so that we can further interact in a customized way with vSphere and the storage controllers.

Would love to see the script if you're willing to share!

-Nick

JEFFREY_BURDZEL
5,294 Views

Hi Nick,

I was able to get the clearance from my company to post my scripts, but I don't see an option for attaching files to a post?  The files are a little lengthyl, but I guess I can strip out all of the fluff and error checking and just post the straight commands?  I'm new to these forums, so if you could give me some guidance on the best way to post the code, it would greatly appreciated!

Thanks,

-Jeff

JEFFREY_BURDZEL
5,295 Views

I figured out how to post files 🙂  Copy these 3 files to the same directory.  These Scripts are meant to be run from the VM that you wish to mount the vmdk file to that you are backing up.  I have them setup to run as a Pre and Post command in Networker so that I can run an EOM backup to tape for a 1 year retention of the data.  The pre script will create a FlexClone from the SMVI snapshot, mount that Snapshot to each of the ESX hosts that are in the cluster of the current Vm running the script, adds the VMDK file to the VM, and then Mounts the new drive to the specified NTFS Mount folder.  The Post script will then Unmount the drive from the host, remove the .vmdk from the VM, remove the datastore from the ESX hosts in the cluster, then delete the flexclone that was created.  For extended help on running these commands, please run 'get-help .\SMVI_Mount_Pre.ps1 -Full' and 'get-help .\SMVI_Mount_Post.ps1 -Full'.  If you have any questions, comments, issues, or if you found these scripts helpful, please feel free to e-mail me at Burdzy@Gmail.com.  If there is enough interest, I can go into more detail on what exactly the script is doing, etc., and add some more comments to the scripts.  I only had a week to get them done, so I skimped on the comments to save time.

Basic examples of running the script(s):

.\SMVI_Mount_Pre.ps1 -NAFilerIP 158.228.1.2 -NAVolume SMVI_test_Volume -SMVIJobName SMVIBackup01 -VMVCenter VirtualCenter01 -VMDKPath "smvit01/smvit01_1.vmdk" -BackupMountPoint "C:\BackupMounts\smvit01\" -Pause

.\SMVI_Mount_Post.ps1 -NAFilerIP 158.228.1.2 -NAVolume SMVI_test_Volume -SMVIJobName SMVIBackup01 -VMVCenter VirtualCenter01 -VMDKPath "smvit01/smvit01_1.vmdk" -BackupMountPoint "C:\BackupMounts\smvit01\" -Pause

In these examples

158.228.1.2                                 is the IP address of the NetApp Filer

SMVI_test_Volume                    is the name of the volume on the NetApp that is being backed up

SMVIBackup01                          is the name of the Backup Job.  SMVI uses this value to name it's SnapShots

VirtualCenter01                         is the name of the Virtual Center that the Current VM Lives in.  This is needed to run the PowerCLI commands against for the datastore and VM configuration

smvit01/smvit01_1.vmdk         is the path to the actual VMDK file within the datastore that is being backed up.

C:\BackupMounts\smvit01\     is the path to the folder that you would like to mount the Drive to on the VM.

-Pause                                        is a switch that will tell the script to pause before executing each command in case you wanted to follow along and validate that each step works correctly.

VM Host Prerequisites:

  • the DataONTap powershell module MUST be installed to configure the NetApp filer
  • VMWare PowerCLI module MUST be installed to configure the Virtual Machine and ESX hosts.
  • SMVIFunctions.ps1 must be in the same folder as the scripts.
  • Please add NetApp user credentials for account that will be running the Script using the following command to prevent having to hardcode usernames/passwords inside the script
         Add-NaCredential -Controller 158.228.1.2 -Credential UserAccount
  • Run the script as an account that has Virtual Center privileges to prevent being prompted for a password for silent execution.
Public