Storage Software
cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Snapshots via SSSU

Daniel Keisling_2
Occasional Advisor

Deleting Snapshots via SSSU

Hello,

I have a process that creates a new snapshot for a LUN every day. I would like to use perl+SSSU (or even just bash) to script deleting the 5 oldest snapshots under that LUN. Has anyone done anything similar? I currently name the snapshots with an appended YYMMDD date, so I could possibly use date math to see the oldest snapshots. If anyone has any examples or any other suggestions to do this, I would be most appreciative. Maybe someone has a script to delete based on creationdatetime on snapshots?

Daniel

 

P.S. This thread has been moved from Disk Array to HP Storage System Scripting Utility (SSSU). -HP Forum Moderator

3 REPLIES
gstonian
Trusted Contributor

Re: Deleting Snapshots via SSSU

You could:

Use sssu to ls vdisk and output it to a file.

Cat the file and strip the relevant LUNS.

Sort the new file (sort filename.txt) with the LUNS you are interested in. If the LUN Names are the same with the exception of dates at the end, it should sort them ok.

Then you can use the above information to read through that file to build a sssu script to delete the first 5 LUNS (oldest) from that file

i.e. output from ls:
> cat testsort
\Virtual Disks\host\D25\ACTIVE\20080910
\Virtual Disks\host\D25\ACTIVE\20080911
\Virtual Disks\host\D25\ACTIVE\20080912
\Virtual Disks\host\D25\ACTIVE\20080902
\Virtual Disks\host\D25\ACTIVE\20080903
\Virtual Disks\host\D25\ACTIVE\20080923
\Virtual Disks\host\D27\ACTIVE\20080929
\Virtual Disks\host\D27\ACTIVE\20080907
\Virtual Disks\host\D27\ACTIVE\20080918

> cat testsort | grep D25 | sort
\Virtual Disks\host\D25\ACTIVE\20080902
\Virtual Disks\host\D25\ACTIVE\20080903
\Virtual Disks\host\D25\ACTIVE\20080910
\Virtual Disks\host\D25\ACTIVE\20080911
\Virtual Disks\host\D25\ACTIVE\20080912
\Virtual Disks\host\D25\ACTIVE\20080923
> cat testsort | grep D25 | sort > testsorted
> (( i = 0 ))
>while read LINE
do
if (( i < 5 ))
then
echo $LINE
(( i=i+1 ))
fi
done < testsorted

Virtual DiskshostD25ACTIVE20080902
Virtual DiskshostD25ACTIVE20080903
Virtual DiskshostD25ACTIVE20080910
Virtual DiskshostD25ACTIVE20080911
Virtual DiskshostD25ACTIVE20080912

Then use this information to build a SSSU Input script to delete these 5 LUNs.
Daniel Keisling_2
Occasional Advisor

Re: Deleting Snapshots via SSSU


Thanks, that's pretty much what I did. It's all working great now.

# Now we need to run through the sorted file and find snapshots not matching the $RETENTION policy

i=1
while read -r LINE
do
if [ i -gt $RETENTION ]
then
delete_snapshot
fi

((i=i+1))

done < $TMP_FILE_SORTED

Daniel Keisling_2
Occasional Advisor

Re: Deleting Snapshots via SSSU

See last post.