Skip to content

Instantly share code, notes, and snippets.

@rome2o
Last active July 5, 2021 03:48
Show Gist options
  • Select an option

  • Save rome2o/0dee2a0553407dad68f6cab2f5577f04 to your computer and use it in GitHub Desktop.

Select an option

Save rome2o/0dee2a0553407dad68f6cab2f5577f04 to your computer and use it in GitHub Desktop.
Dokku Cheat Sheet - 2021

Dokku Cheatsheet

Hi! I thought to put this altogether for people who are running Dokku to be able to quickly find some workflows of Dokku.

Last updated: 7 July 2021

Databases

We assume that our primary database is hellodb. When executing the commands, it needs to be replaced with the name of your database. Most of the commands are interchangeable with Postgres and MySQL, just replace mysql with postgres in the command itself.

Database commands

Create Database

MySQL
dokku mysql:create hellodb
Postgres
dokku postgres:create hellodb

Create Database with specified version

dokku mysql:create hellodb -I 8.0

Clone Database

MySQL
dokku mysql:clone hellodb newhellodb
Postgres
dokku postgres:clone hellodb newhellodb

Upgrade Database

MySQL

WARNING: Always remember to take your backup before running the following command.

dokku mysql:upgrade hellodb -I 8.0

Where 8.0 is the version of MySQL. Please note that 8.0 is not currently compatible with Sequel Pro but works fine with DBeaver!

Backup - S3 Bucket

Authorisation is required before you could backup on a S3 Bucket..

dokku mysql:backup-auth hellodb <aws-access-key-id> <aws-secret-access-key> us-east-1 s3v4 <endpoint-url>

If you are using any other object storage than AWS itself - you only need to change the access-key-id, aws-secret-access-key and endpoint-url! Remember that the us-east-1 s3v4 remains static as per above.

Generate backup to S3 Bucket

dokku mysql:backup hellodb <folder-name>

Replace the folder name accordingly, if the folder doesn't exists - it will be created!

Schedule backup to S3 Bucket

dokku mysql:backup-schedule hellodb "0 3 * * * " <folder-name>

Where 0 3 * * * is the cron schedule expression to run these tasks timely. Use service similar to Crontab.guru to generate cron schedule expressions.

Unschedule a backup

dokku mysql:backup-unschedule <folder-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment