Skip to content

How to Restore DigitalOcean Environment⚓︎

Summary⚓︎

This article falls under the category of Disaster Recovery. It will serve as a step-by-step guide for restoring my entire DigitalOcean environment in the event of a disaster.

Note

This article should be used as a general overview and may vary slightly from a real world scenario.

Considerations⚓︎

There are currently a number of safeguards in place to make sure that my DigitalOcean environment can be restored, which are listed below:

Snapshots⚓︎

  • The quickest and most basic method of restoration. Automatic snapshots are created daily at 2am.
  • Contingent on retaining access to DigitalOcean account.

File Backups⚓︎

  • Rclone and cron are used extensively on the do-docker droplet to backup the following to Backblaze B2:
# Unifi Backup
0 1 * * * rclone sync /home/unifiadmin/.config/appdata/unificontroller/data/backup/autobackup b2:ImageBackup/Unifi --verbose --log-file=/home/unifiadmin/logs/unifi_b2.log && curl -fsS --retry 3 -o /dev/null https://hc-ping.com/a0d8acd9-bc47-498c-a184-7464eb362793

# Ghost Backup
30 1 * * 1 rclone copy /opt/ghost_content b2:DigitalOcean-DB-Backup/ghost && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/a7c0cf6e-7c33-4e59-9b5f-6fae1f6c32b7

# Wallabag Backup
0 1 * * 1 rclone copy /opt/wallabag b2:DigitalOcean-DB-Backup/Docker/Volumes/wallabag && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/6bae6a26-7b11-4e63-baab-7cf14e341f15

# Monica Backup
0 2 * * 1 rclone copy /opt/monica b2:DigitalOcean-DB-Backup/Docker/Volumes/monica && curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/cf11ef1f-4289-4cf8-8d25-41be5fe936c6

Databases⚓︎

DigitalOcean Managed Database

  • Automatic point in time backups managed by DigitalOcean.
  • Additional daily backup of Bookstack database done by Snapshooter.io and sent to B2.

Git⚓︎

The following configurations are regularly backed up to GitHub:

Disaster Recovery⚓︎

The following instructions can be used as a guide in order to restore an entire environment:

  • Create a new droplet from scratch using Ubuntu.

Note

The size of the droplet should not necessarily matter as it can always be scaled, but at the time of this writing, the droplet details are as follows:

Image Ubuntu (docker-s-1vcpu-2gb-nyc1-01)
Size 1vCPUs 2GB / 50GB Disk ($10/mo)
Region NYC1
IPv4 161.35.253.70
IPv6 N/A
Private IP 10.116.0.5
VPC default-nyc1

Tip

Check Docker-Compose.yml file to make sure any environment variables are accounted for and volume locations exist.

  • Use rclone to restore Unifi, Ghost, Monica & Wallabag using the following syntax:
# Unifi Restore
rclone copy b2:ImageBackup/Unifi /home/unifiadmin/.config/appdata/unificontroller/data/backup/autobackup

# Ghost Restore
rclone copy b2:DigitalOcean-DB-Backup/ghost /opt/ghost_content

# Wallabag Restore
rclone copy b2:DigitalOcean-DB-Backup/Docker/Volumes/wallabag /opt/wallabag

# Monica Restore
rclone copy b2:DigitalOcean-DB-Backup/Docker/Volumes/monica /opt/monica
  • Additionally, restore Heimdall to the /home/unifiadmin/.config/appdata/heimdall folder with rclone.
  • rclone copy b2:DigitalOcean-DB-Backup/Docker/Appdata/heimdall /home/unifiadmin/.config/appdata/
  • Install Nginx with sudo apt install nginx -y.
  • Restore Nginx configurations to /etc/nginx/sites-available and /etc/nginx.
  • Create any symlinks as necessary
sudo ln -s /etc/nginx/sites-available/<service>.conf /etc/nginx/sites-enabled/<service>.conf
  • Reload Nginx as necessary with sudo service nginx restart.
  • Install Searx
  • Consider the database to be fully operational, but should it need to be restored from a backup, reference the backup and restore a MySQL database article.
  • Migrate an existing MySQL database with the following command:
mysql -u doadmin -pshow-password -h db-mysql-nyc1-79999-do-user-6634872-0.a.db.ondigitalocean.com -P 25060 < <local-sql-dump-path>
  • Update Cloudflare DNS records with a new public IP if necessary.
  • Verify connectivity of all services to ensure everything came back as it should with all data intact.