Hello
I’m trying to do something kinda complex, and I was doing it manually before n8n
Describe the issue/error/question
So, I’ve 2 Droplets in DigitalOcean, Mail / Site, and every week I do these steps manually:
I shutdown both of them
take a snapshot of both droplets named with the date taken (ex: mail-06-10-2022 / site-06-10-2022)
Delete the old snapshots
PowerOn the Droplets
–
So to reproduce that in n8n, I’ve faced a couple of issues:
a first issue is that I have to delete the old droplet snapshots first because if toke the new snapshots and when listing all snapshots, I didn’t figure out how to choose the old snapshots only and delete them.
So to pass this issue, I made a request to [List all Snapshots] then [Delete Snapshots] via DigitalOcean API
a second issue is how to determine if the snapshots complete to Power On the Droplets again
So, I think I have to use [wait] and [IF] to check if the Droplet Snapshot Creation is completed or not, and if not completed [False] then [loop] to the [wait] again and check with [IF] again, and if it complete[True], then [Power_On] the Droplet and send a [Telegram] message
And i don’t know how to make this task, i don’t know how to check if the snapshot completed !
Sounds like quite a complex workflow you’re trying to build here.
Unfortunately, it’s not clear to me which problems exactly you are facing. Perhaps we can break this down and take things step by step.
a first issue is that I have to delete the old droplet snapshots first because if toke the new snapshots and when listing all snapshots, I didn’t figure out how to choose the old snapshots only and delete them.
Are you already reading the old snapshots successfully? How does the JSON data you’re getting from Digital Ocean look like and based on which criteria do you determine whether a snapshot is old and should be deleted?
I tried to filter the output by the created_at parameter, the query might be NOT LIKE date()
and NO luck with that (If You can help with that, then this issue is fixed),
So, I’ve decided to Delete all Droplet snapshots first, then later create new snapshots
and here’s what i build for this section to delete all old snapshots
And when the IF statment is Truem then it goes to takeing snapshots process
I’d say if it works and is readable it’s a good workflow.
However, from looking at the screenshot showing the response from the “List Droplet Snapshots” HTTP Request node it’s not clear to me how you’d identify old snapshots. Are you simply trying to delete all old snapshots, and not those with a minimum age?
If it’s the latter it might be worth splitting out the snapshots array using the Item Lists node, then checking if created_at is older than your minimum age using an IF node.
Yes, I’m deleting all snapshots
Can you please tell me how to make the query of filtering the snapshots with created_at to only get snapshots with less than today’s date ?
and also i don’t know how to use the item lists node
Can you please tell me how to make the query of filtering the snapshots with created_at to only get snapshots with less than today’s date ?
and also i don’t know how to use the item lists node
Hi @MotazHakim, I don’t have a Digital Ocean account, so can’t provide real test data here. However, something like this should do the job I think:
Let me know if you have any questions on the steps in the above workflow.