Using CLI When Droplet Powered Off

April 21, 2014 2k views
I'm trying to run part of the shell script found at... https://www.digitalocean.com/community/articles/how-to-scale-your-infrastructure-with-digitalocean ...to be able to take a snapshot. However, the snapshot function within the script returns an error message. {"status":"ERROR","error_message":"Droplet is currently on. Please power it off to run this event.","message":"Droplet is currently on. Please power it off to run this event."} So I power off. But since the system is now down, I can't run the shell program via the terminal. In searching for solutions with other articles and finding this one... https://www.digitalocean.com/community/articles/how-to-use-digitalocean-snapshots-to-automatically-backup-your-droplets ...,it too recommends powering off the droplet first, then to use curl and commands through the CLI . However, the terminal window, usually available through Digital Ocean, is not viewable when the droplet is off. Nor can I connect through my PC's terminal with ssh. How does one use CLI/terminal with a droplet powered off? I'm probably overlooking something simple but can't realize it. Many thanks to an answer.
4 Answers
In both cases, the commands are meant to be run on the command line of a different machine than the droplet you want to snapshot. If you are using Mac or Linux, you can just use the terminal that came with the OS. If you are on windows you could run it from another droplet, or look into something like Cygwin:


Thanks again for the reply.

Just to clarify and to state my current understanding of this problem...

I need to spin a 2nd droplet and operate off of this active server, in order to be able to run a script to make a snapshot for the 1st droplet, which has to be powered off, in order to make the snapshot.

That possessing just one droplet in power off mode won't work, since 1) D.O.'s terminal for a shutdown droplet is not able to be accessed, and therefore can't run the script, and 2) my PC's Linux terminal won't connect to a shutdown droplet, again, not allowing me to run the script.

Overall, two droplets are needed. Is this right or am I still overlooking something? Thanks.
From your PC's Linux terminal, you do not need to connect to the powered off droplet to take the snapshot. You need to make a call to DigitalOcean's API. For example, on your local PC, run this from the command line (using your real client ID and API key):

curl -X GET "https://api.digitalocean.com/droplets/?client_id=$DO_CLIENT_ID&api_key=$DO_API_KEY"

It should return a JSON string that lists your droplets and information about them. You can do the same to take a snapshot.

curl -s "https://api.digitalocean.com/droplets/$DROPLET_ID/snapshot/?client_id=$DO_CLIENT_ID&api_key=$DO_API_KEY"

So if you want to use the script from the tutorial, just download it and use it locally.
Running locally did it. Everything works.

I appreciate your help.
Have another answer? Share your knowledge.