Last active
July 9, 2016 09:54
-
-
Save Jbithell/398e4cd1662abe9fa936750338962763 to your computer and use it in GitHub Desktop.
A system for snapshotting a droplet itself on DO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#THIS SCRIPT MUST BE RUN AS ROOT | |
token="" | |
dropletid="" | |
dumpmysqlpass="password" #Set this to what you set in the setup! | |
cd / | |
mysqldump -u dump -p $dumpmysqlpass --all-databases > /databasebackup.sql #Dump the MySQL | |
doctl compute droplet-action snapshot $dropletid --wait --snapshot-name "Regular Auto Snapshot whilst running." -t $token #Run the snapshot | |
rm -r /databasebackup.sql #We no longer need that MySQL dump | |
cd / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
MySQL
Install Doctl
Crontab
Pop this script in your crontab - though remembering it must be run as root