1

I am in need of situation where i need to list out the available droplet snapshot of specific droplet. I am using doctl to list the snapshots. I need a way that the doctl command needs to list out the available snapshots along with date of creation. Alternate solutions is also appreciated. I am not sure is this possible. It would be great help if some one render their hands to make it clear.

Thanks, Muneesh

2 Answers2

1

Your question is unclear.

Do you wish to filter the list of snapshots by a given Droplet (ID)?

If so, I suspect you'll want to consider using doctl --output=json to get the doctl command's output as JSON and then use a tool like jq to filter the result.

I created a Droplet and a snapshot and this works:

# jq filter
FILTER=".[]|select(.resource_id==\"${DROPLET}\")"

# For all my Droplets
DROPLETS=$(doctl compute droplet list --format=ID --no-header)

for DROPLET in ${DROPLETS}
do
  doctl compute snapshot list \
  --resource=droplet \
  --output=json \
  | jq "${FILTER}"
done

And, if you want to limit the output to just name and created_at:

FILTER=".[]|select(.resource_id==\"${DROPLET}\")|{\"name\":.name,\"created\":.created_at}"
DazWilkin
  • 32,823
  • 5
  • 47
  • 88
0

The command exists:

doctl compute snapshot list

Here is the official documentation.

Iacchus
  • 2,671
  • 2
  • 29
  • 24