Array Setup and Networking
1752685 Members
5484 Online
108789 Solutions
New Discussion юеВ

Re: Need Command Line to delete Volume Collection Snapshots based on date or age of the snapshot.

 
SOLVED
Go to solution
jirizarry76
New Member

Need Command Line to delete Volume Collection Snapshots based on date or age of the snapshot.

I am using Volume collections for our Oracle Volumes and performing snapshots using the CLi to do Begin/End Backup Mode.

The naming of the snapshots is dynamic to include date/time info. I need a way to delete old snapshots via command line.

I would like to keep a max of 15 snapshots, I take snapshots every 15 mins.

Regards

Juan C. Irizarry

3 REPLIES 3
rhamilton59
New Member

Re: Need Command Line to delete Volume Collection Snapshots based on date or age of the snapshot.

Juan,

The "CLI Reference Guide" can be found on InfoSight. Once you login to InfoSight, click on the download icon in the top right portion of the page. Under the "Nimble OS" tab, select your software version and then select the "CLI Reference Guide" below. In this document, you will find the commands needed to manage your array. The information you are looking for will probably be in Chapter 36 (~page 259.)

Regards,

Robert

aherbert23
Trusted Contributor
Solution

Re: Need Command Line to delete Volume Collection Snapshots based on date or age of the snapshot.

If your snapshots follow a specific naming scheme you could use the snapshot collection list to find the ones you want to remove. For example the following line will find all the snapshots that are in the VMware volume collection that have the keyword "hourly" in the name. It then reverse sorts the snapshots based on the date in the name from newest to oldest and only shows the ones after the first 15 lines. Then the tr and cut commands show just the snapshot name.

Nimble OS $ snapcoll --list --volcoll VMware | grep hourly | sort -r -k2 | tail -n +15 | tr -s " " | cut -d " " -f 2
VMware-hourly-2015-06-17::19:00:00.000
VMware-hourly-2015-06-17::18:00:00.000
VMware-hourly-2015-06-17::17:00:00.000

This can then be used in a for loop to remove those snapshots.

for x in `snapcoll --list --volcoll VMware | grep hourly | sort -r -k2 | tail -n +15 | tr -s " " | cut -d " " -f 2`; do snapcoll --delete $x --volcoll VMware; done
jirizarry76
New Member

Re: Need Command Line to delete Volume Collection Snapshots based on date or age of the snapshot.

thanks a lot buddy.