By Vic Jones
Hey All,
I want to create a script that will create a snapshot of a droplet, then add that snapshot to another region for redundancy. Is is possible to do this through the DO API?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Yes. The DigitalOcean API supports both taking a snapshot of a Droplet and transferring a copy of it to additional regions.
I’ve linked to the relevant API docs above, but here’s a quick example using doctl, the DigitalOcean CLI:
SNAPSHOT_NAME="snapshot-$(date +%s)"
doctl compute droplet-action snapshot $DROPLET_ID \
--snapshot-name $SNAPSHOT_NAME \
--wait
IMAGE_ID=`doctl compute image list-user --no-header --format Name,ID \
| grep $SNAPSHOT_NAME \
| tr -s ' ' \
| cut -d ' ' -f2`
doctl compute image-action transfer $IMAGE_ID \
--region $NEW_REGION
--wait flag. This blocks until the snapshot has been completed.--wait flag here if you want the script to block until the transfer is complete.Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.