cloudstack-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag Sonstebo <>
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

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).

Dag Sonstebo
Cloud Architect

On 11/11/2016, 14:04, "Alessandro Caviglione" <> 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!!
53 Chandos Place, Covent Garden, London  WC2N 4HSUK

View raw message