Automate the upgrade of your DigitalOcean droplets

Recently DigitalOcean released new pricing plans where they basically doubled the RAM for the same price of the old plans. But to get the benefits for your existing droplets, you have to upgrade all of your existing droplets in a process that involves shutting them down, selecting the new plan, waiting for the upgrade to happen and power on the droplets again. I have tens of droplets and had no intention of doing this manually, so I wrote a script to use the DigitalOcean API to automate a mass-upgrade of all droplets.

You need to have the PHP package manager Composer installed.

Then all you need to do is:

    1. Install the script by running
      composer create-project bjornjohansen/do-upgrade-plans
    2. Get your Personal Access Token with read and write access, which you can generate on the Applications & API page.
    3. Copy your access token and set it as an environment variable:
      export DO_ACCESS_TOKEN=<YOUR_64_CHAR_TOKEN_HERE>
    4. Run the script:
      php -f do-upgrade-plans/do-upgrade-plans.php
    5. Watch your droplets get upgraded.

In case an error happens, your droplets will power cycle, to make sure they are in a running state. This happened to 3 of my ~60 droplets. Further investigation (trying to upgrade manually) revealed that “Due to high demand and capacity restrictions we have temporarily disabled this size in this region.” – so oh, well, guess I’ll upgrade those droplets later.

If you want to inspect the script or make a Pull Requst, it is available on GitHub.

Please note that some downtime is expected. The script is something I pulled together on an evening to serve my need, it is quite crude: it works fine if you have tens of droplets like I do. If you have hundreds of droplets, or a high availability setup behind a load balancer, you will want to customize the script somewhat. The longest downtime I had, was 5 minutes and 3 seconds, but YMMV.

1 Comment

  1. Today I received an email from DigitalOcean, explaining why the droplets I tried to upgrade failed:

    Hello,

    Following the launch of our new pricing plans, we have seen a significant uptick of usage in our AMS2 region and we have currently reached maximum capacity at the datacenter. As a result, we have disabled new Droplet creation in the region.

    Though we are making efforts to free up space on our servers, we are unable to add more capacity as we remain restricted by the size of the facility. We anticipate that some users will destroy their AMS2 Droplets, freeing up space in the region, but we are unable to predict how much space that will create, and how quickly that might happen. We encourage you to consider migrating your data to our AMS3 region – which houses newer hardware and more features, like Block Storage – or to one of our other nearby regions like LON1 or FRA1.

    For more information about migrating your Droplets to a new region, you can refer to this tutorial on our Community site.

    Thank you,
    Team DigitalOcean

Comments are closed.