Many Powershell cmdlets have been developed for NetApp Data ONTAP. This is true for both 7-mode and cluster-mode. Since the cluster-mode cmdlets are relatively new, we’ll take a close look at it here, using a couple cluster-mode cmdlets to demonstrate how to create a volume snapshot and then restore it.
First, two prerequisites:
· Powershell v2.0, which you can download and install from the Microsoft website here.
· Data ONTAP Powershell Toolkit v1.7, or DataONTAP.zip, you can download from NetApp Community here (see Fig.1). You need to login with your NOW credential to download.
Figure 1: Download DataONTAP.zip from NetApp Community
Note: for Powershell background info, here are some useful websites with good info:
After you downloaded the ONTAP Powershell Tool Kit v1.7, on your Windows host, open a command prompt, create a directory C:\psontap. Unzip the DataONTAP.zip kit to C:\psontap\DataONTAP. Fig. 2 shows the contents after unzipping the tool kit.
Figure 2: Unzip DataONTAP.zip
Next, open a powershell prompt by clicking on the icon (see Fig. 3).
Figure 3: Click on the Powershell icon to open the Powershell command prompt
Then, initialize the ONTAP Powershell Tool Kit using import-module dataontap, as shown in Fig. 4.
Figure 4: Import the DataONTAP module
To distinguish cluster-mode cmdlets from 7-mode ones, the mnemonic ‘Nc’ is used. For example, to create a snapshot, you use New-NaSnapshot in 7-mode, but New-NcSnapshot in cluster-mode. Therefore, to discover all the snapshot cmdlets in cluster-mode, you can simply do get-help *NcSnapshot*, as show in Fig. 5. Note, the whildcard is allowed in cmdlets.
Figure 5: Cluster-mode snapshot cmdlets
In order to take a volume snapshot (or manage the FAS controller), you first need to use the cmdlet connect-NcController to establish communication with the NetApp FAS controller (operating in cluster-mode) from your Windows box (see Fig. 6). When prompted, type in the admin password and hit OK. Note again the cmdlet is cluster-mode because of the presence of ‘Nc’.
Figure 6: Establish connection to a FAS controller operating in cluster-mode
Create a Snapshot
Figure 7 shows how to use the Powershell cmdlet New-NcSnapshot to create a volume snapshot called mysnap. Note that here we assumed that the FlexVol volume test_fv and Vserver vc1 are already on the controller. The parameter VserverContext is useful because it can uniquely identify the volume belonging to the specific Vserver, if there are multiple volumes named test_fv while belonging to different Vservers.
Figure 7: Create a snapshot in cluster-mode using Powershell cmdlet
Restore a Snapshot
Suppose after sometime you want to restore the snapshot mysnap for whatever reason, you can do that by using the cmdlet restore-NcSnapshotVolume, as shown in Fig. 8. The parameter PreserveLunIds allows the LUNs within the volume being restored to stay mapped and their identities preserved.
Figure 8: Restore a volume snapshot
You can explore other cluster-mode snapshot cmdlets by doing get-help <cmdlet> for each cmdlet shown in Fig. 5. I found these cmdlets are quite straightforward to use, although a little bit verbose. And of course, if you have many volumes and snapshot copies, you can write your own scripts based on these cmdlets to streamline the operations.
Thanks for reading.