# Nightly DigitalOcean Droplet snapshots with auto-cleanup

> Back up your DigitalOcean servers every night, automatically delete snapshots past your retention window, and get a Slack recap of exactly what changed.

- Workflow type: code
- Services: DigitalOcean, Slack Bot
- Categories: Engineering, Operations
- Published: 2026-07-17

## What it does

- Runs every night and takes a fresh snapshot of every DigitalOcean server you have tagged for backup
- Automatically deletes older snapshots so you only keep the most recent few per server and control storage costs
- Posts a Slack summary of which servers were backed up and which old snapshots were removed
- Flags a warning in Slack if any backup or cleanup step failed, so nothing silently breaks

## What you'll need

- A DigitalOcean account with the servers you want to back up
- A tag on those servers (for example "backup") so the workflow knows which ones to snapshot
- A Slack workspace and the channel where you want the nightly summary posted

## Prompt

Every night at 2:00am, snapshot my tagged DigitalOcean Droplets, prune old snapshots beyond a retention window, and post a summary to Slack. Use a cron trigger set to run once nightly at 02:00.

Expose these settings at the top of the workflow so they are easy to change: the Droplet tag to back up (default "backup"), the retention count (default: keep the 7 most recent snapshots per Droplet and delete the rest), the snapshot name date format (default YYYY-MM-DD), and the Slack channel to post the summary to.

Step 1 - find the Droplets. Call DigitalOcean's List All Droplets operation filtered by the configured backup tag to get the set of Droplets to snapshot. If none match the tag, skip straight to the Slack step and report that nothing was tagged for backup.

Step 2 - take snapshots. For each Droplet, call Initiate a Droplet Action with type "snapshot" and a name built from the Droplet name plus the current date in the configured date format (for example "web-01-2026-07-17"). Alternatively, use Act on Tagged Droplets to snapshot the whole tag in one bulk call. Remember that DigitalOcean Droplet actions are asynchronous: each call returns an action object with an id and a status. Collect every returned action id.

Step 3 - wait for completion. Poll Retrieve a Droplet Action for each action id until its status is "completed" or "errored", waiting a few seconds between polls and capping the total wait so the workflow cannot hang forever. Record which Droplets completed successfully and which returned an error.

Step 4 - prune old snapshots. After the new snapshots exist, list the snapshots for each Droplet with List Snapshots for a Droplet (or use List All Snapshots for the whole account and group them by Droplet). Sort each Droplet's snapshots newest first, keep the number set by the retention count, and call Delete a Snapshot for every snapshot beyond that window. Track which snapshot names or ids were deleted per Droplet.

Step 5 - confirm in Slack. Finish by using the Send a Message action (posting as the Slack bot) to the configured channel with a summary: list which Droplets were snapshotted and which old snapshots were deleted per Droplet. If any snapshot action returned status "errored", any poll timed out, or any delete call failed, add a clearly marked warning line at the top naming the affected Droplets so the failure is not missed.

## How to customize

- Change which servers get backed up by editing the tag it looks for
- Set how many snapshots to keep per server before older ones are deleted (the default keeps the 7 most recent)
- Adjust the run time, the date format used in snapshot names, and the Slack channel

## FAQ

### How does this save money on DigitalOcean storage?

Snapshots are billed monthly per gigabyte, so old backups quietly add up. By keeping only the most recent few per server and deleting the rest every night, you stop paying for backups you no longer need.

### Which servers get backed up?

Only the DigitalOcean servers you have given a specific tag, "backup" by default. Tag a server to include it or remove the tag to leave it out, without editing the workflow.

### What happens if a backup fails?

The Slack summary includes a clear warning line naming any server whose snapshot or cleanup did not complete, so you can look into it right away instead of finding out later.

### Will it ever delete a backup I still need?

It only removes snapshots beyond the retention count you set and always keeps the newest ones. Raise the count if you want to hold on to a longer history.

### Can I change when it runs?

Yes. It is set for 2am nightly by default, but you can move it to any time or frequency that fits your maintenance window.

Use this prompt in General Input: https://www.generalinput.com/prompts/nightly-digitalocean-droplet-snapshots-with-auto-cleanup