7 Replies Latest reply: Oct 23, 2013 10:11 AM by justin.smith RSS

Script to list snapshot copies of all volumes

justin.smith Sprinter
Currently Being Moderated

Im looking for a script that will give me the snapshot copies names, date/time, size, etc for each individual volume on a filer.

 

Preferably I'd like something exported to excel that would show me:

 

Volume Name

     Snapshot copy name

     Snapshot copy name

 

Based on the screen shot the output would be this:

 

testSM

     hourly.0   

     hourly.1

     nightly.0

     hourly.2

 

Etc....

 

Doable?

  • Re: Script to list snapshot copies of all volumes
    olson NetApp Employee CertifiedPlus Sprinter
    Currently Being Moderated

    Justin,

     

    One way to do this is with the data ontap powershell toolkit

     

    Import-Module dataontap

    Connect-NcController Mycluster or

              connect-nacontroller filer

     

    Get-NcSnapshot|Export-Csv mysnapshots.csv  or

               Get-NaSnapshot|Export-Csv mysnapshots.csv

     

    You could also limit down the output by specifiy the volume or the svm(vserver) volume name pattern.

     

    Regards

    John

    • Re: Script to list snapshot copies of all volumes
      justin.smith Sprinter
      Currently Being Moderated

      Im familiar with the OnTap toolkit.

       

      It doesnt like the Get-NcSnapshot command:

       

      Get-NcSnapshot : Value cannot be null.

      Parameter name: Controller parameter neither specified nor set in $global:CurrentNcController

       

      Here's my script:

       

      Import-Module dataontap

      Connect-nacontroller REALFILERNAME -Credential jsmith

      Get-NcSnapshot|Export-Csv mysnapshots.csv

      • Re: Script to list snapshot copies of all volumes
        justin.smith Sprinter
        Currently Being Moderated

        Looks like thats a cluster mode command?

        I think Im figuring it out, Im using the get-nasnapshot command which is for 7 mode. The only thing is, I need it to grab ALL volumes.

         

        Import-Module dataontap

        Connect-nacontroller REALFILERNAME -Credential jsmith

        Get-NaSnapshot|Export-Csv 'H:\NetApp Scripts\snapshots.csv'

         

        What happens is it asks me for a TargetName for the volumes.

        • Re: Script to list snapshot copies of all volumes
          olson NetApp Employee CertifiedPlus Sprinter
          Currently Being Moderated

          sorry about that syntax for the cdot is slightly different.

           

          This should do it for you.

           

          Import-Module dataontap

          Connect-NaController [filer] -Credential root

          get-navol|get-nasnapshot|Export-Csv mysnapshots.csv

          • Re: Script to list snapshot copies of all volumes
            justin.smith Sprinter
            Currently Being Moderated

            That seemed to work....

             

            Only thing is it gives me the info bassackwards.

             

            Is there a way to get the TargetName on the first column of the spreadsheet?

            • Re: Script to list snapshot copies of all volumes
              olson NetApp Employee CertifiedPlus Sprinter
              Currently Being Moderated

              Your welcome!

               

              You can format the output with the select command.

               

              get-navol|get-nasnapshot |select TargetName,name,Created|Export-Csv mysnapshots.csv

              You can select any of the rows in the header.


              Created

              Cumulative

              AccessTime

              AccessTimeDT

              Busy

              ContainsLunClones

              CumulativePercentageOfTotalBlocks

              CumulativePercentageOfUsedBlocks

              CumulativeTotal

              Dependency

              Name

              PercentageOfTotalBlocks

              PercentageOfUsedBlocks

              SnapshotOwnersList

              TargetName

              TargetType

              Total

              ContainsLunClonesSpecified

               

              Regards,

              John

              • Re: Script to list snapshot copies of all volumes
                justin.smith Sprinter
                Currently Being Moderated

                Thanks, that worked too... last question.

                 

                Here's my current script:

                 

                Import-Module dataontap

                $Controller = @('filername')

                Foreach ($filer in $controller)

                {

                Connect-nacontroller $filer -Credential jsmith

                get-navol | get-nasnapshot | select TargetName,name,Created | Export-Csv 'H:\NetApp Scripts\$filer.snapshots.csv'

                }

                 

                Im looking for it to save the file with the filername.snapshot. I've tried filername_snapshot and filername.snapshot, but it only gives it the $filer.snapshot name.....

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points