cloudstack-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag Sonstebo <Dag.Sonst...@shapeblue.com>
Subject Re: Manual Volume Snapshot retention
Date Fri, 11 Nov 2016 14:48:27 GMT
Hi Alessandro,

“Jq” is your friend here. You would start by just listing all the volume snapshot ordered
by create time – whilst also capturing the snapshot ID:

# cloudmonkey list snapshots volumeid=21f830d8-b182-41dc-8a10-48ff0a07f299 | jq -r '.snapshot[]
| .created + "|" + .id' | sort -r
2016-11-11T14:41:59+0000|418075c1-bcfc-4b9f-b2f2-4e11fb3e111c
2016-11-11T14:41:29+0000|363129bd-ee9b-4301-b46b-a09291f05b98
2016-11-11T14:39:52+0000|fd51897e-725f-40b0-a07d-7bad6cbd7c89
2016-11-11T14:32:57+0000|7f2a7b7d-789d-4056-b287-9b8f8e113e76

Now that you have this list all you need to do is parse it, i.e. any id entries in line 22
onwards you need to delete, whilst also comparing the date stamp with (today – 7days).

Keep in mind your logic though: you should probably retain 21 snapshots no matter what the
age is – if your snapshot script fails to take snapshots – and you delete all snapshots
older than 7  days you could end up deleting all snapshots… (just my twopence worth).


Regards,
Dag Sonstebo
Cloud Architect
ShapeBlue

On 11/11/2016, 14:04, "Alessandro Caviglione" <c.alessandro@gmail.com> wrote:

    Hi guys,
    I've a Cloudmonkey script under cron that create a Volume Snapshot of a VPS
    at certain hours.
    I had to create this script because client wants to have more than one
    Snapshotfor each day, so through GUI this is not possible.
    Now, could someone help me to delete old Snapshot in the scripts?
    I need to retain 21 Snapshots or delete Snap older than 7 days.
    
    Thank you!!
    


Dag.Sonstebo@shapeblue.com 
www.shapeblue.com
53 Chandos Place, Covent Garden, London  WC2N 4HSUK
@shapeblue
  
 

Mime
View raw message