Validated on 15 Mar 2019 • Last edited on 8 Jul 2024
disk image
Backups are automatically-created disk images of Droplets. Enabling backups for Droplets enables system-level backups at weekly or daily intervals, which provides a way to revert to an older state or create new Droplets.
Backups and snapshots are both disk images of Droplets. Backups are taken automatically either weekly or daily. We retain weekly backups for four weeks and daily backups for seven days. We retain snapshots until you choose to delete them. If you want to keep a backup indefinitely, you can convert it to a snapshot.
Note
When a backup is converted to a snapshot, snapshot pricing applies.
Convert to a Snapshot using the API
To convert a backup to a snapshot using the API, use the image actions endpoint and set the type field to convert.
How to Add an Image to a Region Using the DigitalOcean CLI
# Transfer an Existing Image
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"type":"transfer","region":"nyc2"}' \
"https://api.digitalocean.com/v2/images/7938269/actions"
# Convert an Image into a Snapshot
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"type":"convert"}' \
"https://api.digitalocean.com/v2/images/7938291/actions"
Go
Using Godo, the
official DigitalOcean V2 API client for Go:
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
// Transfer an existing image
transferRequest := &godo.ActionRequest{
"type": "transfer",
"region": "nyc2",
}
# Transfer an Image
transfer, _, err := client.ImageActions.Transfer(ctx, 7938269, transferRequest)
# Convert an Image to a Snapshot
# client.image_actions.convert(image_id: 7938269)
}
Ruby
Using DropletKit,
the official DigitalOcean V2 API client for Ruby:
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)
# Transfer an Image
client.image_actions.transfer(image_id: 7938269, region: 'nyc2')
# Convert an Image to a Snapshot
# client.image_actions.convert(image_id: 7938269)
Python
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"type": "convert"
}
resp = client.image_actions.post(image_id=342341, body=req)
Convert to a Snapshot using the Control Panel
To convert a backup to a snapshot, from the control panel, find the selected Droplet and click its X backup(s) dropdown. Backups remain available for four weeks after creation, even if the associated Droplet has since been deleted.
Find the backup and click More to open the dropdown menu, then click Convert to snapshot.