Skip to content

m8bsd/droplets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

283 Commits
 
 
 
 
 
 

Repository files navigation

DigitalOcean Snapshot Automation (Makefile)

This project provides a simple Makefile-based automation for managing DigitalOcean droplets and snapshots باستخدام curl و jq.

It replicates the behavior of the original PHP script:

  • 📦 Creates snapshots for droplets with a specific tag
  • 🧹 Deletes old snapshots based on rules

⚙️ Requirements

Make sure the following tools are installed:

  • curl
  • jq
  • GNU date (Linux environment recommended)

Install jq on Ubuntu/Debian:

sudo apt install jq

🔧 Configuration

Edit the Makefile and update:

TOKEN := TOKEN HERE
TAG   := TAG NAME HERE
  • TOKEN: Your DigitalOcean API token
  • TAG: Tag used to filter droplets

🚀 Usage

Run everything:

make

Run individual tasks:

List droplets:

make droplets

List snapshots:

make snapshots-list

Delete old snapshots:

make cleanup

Create new snapshots:

make snapshots

🧠 Logic

Snapshot Cleanup Rules

  • Deletes snapshots if:

    • They are not created on Friday, OR
    • They are created on Friday but older than 7 days

Snapshot Creation

  • Finds all droplets with the specified tag
  • Creates a snapshot for each droplet

⏱️ Automation (Cron Job)

To run daily at 2 AM:

crontab -e

Add:

0 2 * * * make -C /path/to/project

⚠️ Notes

  • Requires a Linux environment (GNU date)

  • macOS users may need to install coreutils and use gdate

  • Ensure your API token has permission to:

    • Read droplets
    • Read snapshots
    • Create snapshots
    • Delete snapshots

📄 License

No license — use it freely.

About

DigitalOcean Snapshot Automation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors