Question

How do I automate snapshots on a weekly basis?

  • Posted October 4, 2014

Hi there,

I was trying to explore the API and such and see what I can do to automate my snapshots, but I’m still a bit lost. For one, I cannot use the API to safely shutdown my droplet (have a support issue open but seems like they consider it “best effort”) and I don’t want to risk a power_off due to this being a production server and writing to a database frequently.

I’m open to scripts, other solutions, advice, etc.

Ultimately, I would like to implement the following as a close example:

  1. Shutdown my droplet at 2 AM every Saturday night
  2. Take a snapshot of the droplet above which would restart the server once its complete
  3. Automate maintenance of those snapshots such as removing the oldest snapshot while only keeping 2 active snapshots, for example.

Does a solution like this exist so that I can automate my snapshots and maintain the images too? At the very least hoping to automate the snapshots and I can manually maintain the images.

Your help would be greatly appreciated, thank you in advance!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

In case people are wondering about easy and free solutions to this problem, we developed a tool for that because we needed daily backups with custom retention in our company: https://github.com/tomochain/goutte

Second part of this tutorial shows how you can setup an automated snapshot capture using ruby script with crontab.

https://www.digitalocean.com/community/tutorials/how-to-use-digitalocean-snapshots-to-automatically-backup-your-droplets

I’m interested to hear if of any solutions people are using for this. There aren’t any public projects doing this that I know of that have set up the automation. Though, there are a lot of different ways to interact with the API that should make taking snapshots simple as well as API wrappers in different languages. Take a look at our projects page for a list.

One popular tool for using the API is Tugboat. Check out the tutorial here. You can snapshot a droplet as easily as running:

tugboat snapshot snapshot_name droplet_name

As the API commands need to be issues from outside of the droplet, you’ll need to use some sort of local automation tool. If you have a Linux box or a Mac, there is always cron.