DigitalOcean Automatic Backups⚓
For my setup, this lives on the 'Yunohost' VM and is located in the folder listed below.
This tool is hosted on my RasPi Zero and MUST not be run with Sudo.
It's located in
Simple Automated offline snapshots of digitalocean droplets utilising [python-digitalocean](https://github.com/koalalorenzo/python-digitalocean). The script safely shutdowns a given droplet or all droplets with a give tag then performs snapshots of them, Then it turns them back on. Every step is logged as well as displayed in the console output. The script is designed to be used as a cron job as well. If any error occurs the script logs it then exits with exit code of 1. Very useful feature to ensure that the backups are successfully completed. I use it to delete older backups only if new one is successful and to use a 'healthchecks' service to get notified if a backup failed. (see cron examples)
Install as a user without sudo. This installs it in ~/.local/bin/ make sure this path is in your $PATH.
If not found, add the following to your .bashrc or .zshrc
Store the api access token in .token file by running '--init' and providing the token string.
To use one of the stored tokens, specify it's index after "dobackup ",
Display Information about droplets and snapshots using --list commands. Examples
Use Tags (optional)⚓
Use tags to backup multiple servers at ones. Use existing tags or create new. Default tag is 'dobackup' . To tag a server with a 'dobakup' tag.
To tag a server with 'web-servers' tag.
In 2.0, --'tag-name'-- is appended to the backup name, instead of hardcoded str '--dobackup--'. The default value of tag_name is still 'dobackup'. Now we can use --tag-name along with --list-backups, --list-older-than, --delete-older-than. Now we can keep the backups of droplets with lets say 'tag1' for 5 days and 'tag2' for 10 days. example command. "--delete-older-than 5 --tag-name 'tag1'" , "--delete-older-than 10 --tag-name 'tag2'"
To backup a server using it's name or id.
To backup all servers that have a given tag.
To set a cron job, to backup all 'tagged' servers and auto delete old backups, if backups were successful
Using amazing utility healthchecks. to get notified if an error occurred during the process.
To restore a server using it's name or id and snapshot's name or id
Delete Old Backups⚓
To delete a specific snapshot.
To delete all old backups taken with dobackup.
usage: dobackup [-h] [-v] [--init] [-l] [--list-backups] [-s] [--list-tagged] [--list-tags] [--list-older-than LIST_OLDER_THAN] [--backup BACKUP] [--backup-all] [--live-backup LIVE_BACKUP] [--live-backup-all] [--tag-droplet TAG_DROPLET] [--untag-droplet UNTAG_DROPLET] [--tag-name TAG_NAME] [--delete-older-than DELETE_OLDER_THAN] [--delete-snap DELETE_SNAP] [--shutdown SHUTDOWN] [--powerup POWERUP] [--restore-droplet RESTORE_DROP] [--restore-to RESTORE_TO] [--keep] [token_id] Automated Offline Or Live Snapshots Of Digitalocean Droplets positional arguments: token_id Specify token number to be used, default=0, supply only if you have multiple Digitalocean accounts optional arguments: -h, --help show this help message and exit -v, -V, --version show programs version number and exit --init Save token to .token file --tag-name TAG_NAME To be used with "--list-tags", "--tag-droplet" and "-- backup-all", default value is "dobackup" --keep To keep backups for long term. "--delete-older-than" wont delete these. To be used with "--backup","-- backup-all" Informational Args: Arguments That Display Information -l, --list-droplets List all droplets --list-backups List all snapshots with "dobackup" in their name -s, --list-snaps List all snapshots --list-tagged List droplets using "--tag-name" --list-tags List all used tags --list-older-than LIST_OLDER_THAN List snaps older than, in days Backup Args: Arguments That Backup Or Restore Droplets --backup BACKUP Shutdown, Backup (snapshot), Then Restart the droplet with given name or id --backup-all Shutdown, Backup (snapshot), Then Restart all droplets with the given "--tag-name" --live-backup LIVE_BACKUP Backup (snapshot), the droplet with given name or id, without shutting it down --live-backup-all Backup (snapshot), all droplets with the given "--tag- name", without shutting them down --restore-droplet RESTORE_DROP Restore, the droplet with given name or id --restore-to RESTORE_TO Snapshot id or name, to restore the droplet to Action Args: Arguments That Perform Actions --tag-droplet TAG_DROPLET Add tag to the provided droplet name or id --untag-droplet UNTAG_DROPLET Remove tag from the provided droplet name or id --delete-older-than DELETE_OLDER_THAN Delete backups older than, in days --delete-snap DELETE_SNAP Delete the snapshot with given name or id --shutdown SHUTDOWN Shutdown, the droplet with given name or id --powerup POWERUP Powerup, the droplet with given name or id