DigitalOcean currently offers weekly automated backups for Droplets. However, you might want to back up your Droplets more frequently. do-snap
is a serverless function that can be deployed on DigitalOcean to take periodic snapshots of a Droplet. It accepts the Droplet ID and a personal access token as input and uses a cron schedule as a trigger. By default, it runs every 6 hours, and you can adjust the frequency.
do-snap
connects to the DigitalOcean API and accesses your account using the provided personal access token. It takes a snapshot of the specified Droplet and deletes an old snapshot, ensuring that only a single snapshot copy is retained at all times.
To use do-snap
, you'll need:
- The latest version of
doctl
with the serverless software installed. - A serverless namespace created and connected to
doctl
. - A personal access token generated for using the DigitalOcean API.
- The Droplet ID or a list of comma-separated Droplet IDs that you want to back up. You can retrieve the Droplet ID.
- Clone this GitHub repository to your local machine.
git clone https://github.com/vprokopov-do/do-snap
- Modify
project.yml
:
- Replace the environment variable
token
with your personal access token. See the next section below for theproject.yml
example. - Replace the environment variable
droplets
with your Droplet ID or list of comma-separated Droplet IDs. - Optionally, rename a Function and a Trigger to names that make sense to you.
- Important: Rename the "your-function-name" directory to match your Function name (if you renamed a Function in step 2).
do-snap
├── project.yml
└── packages
└── do-snap
└── your-droplet-name
└── snap.py
- Optionally, modify
project.yaml
to adjust the cron schedule (it runs every 6 hours by default). - Use
doctl
to Deploy the Function on DigitalOcean.
doctl serverless deploy do-snap
Note that you need to run the deploy command on the entire cloned-down folder.
If you wish to learn more about DigitalOcean's services, feel free to contact me at vprokopov@digitalocean.com. You are also welcome to reach out to the sales team at sales@digitalocean.com. A global team of talented engineers will be happy to provide assistance.