For a Django web app I run, I wanted to set up more-frequent backups of the database to S3 storage. It turned out to be simpler than I thought, because the site runs on Dokku and the database plugin supports encrypted backups to S3. Initially, I looked at the write-up in this post, but quickly found a few mistakes in the example code and instead looked at the examples in the database plugin’s excellent documentation. Thanks Thom as well for the advice on configuring the S3 bucket.
The short version of the steps to set it up is:
# Authenticate with AWS # <service> is the name of the database service you created # and linked to your app dokku postgres:backup-auth <service> AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY # Encrypt backups # I used 1Password to create and store the passphrase dokku postgres:backup-set-encryption <service> <passphrase> # Create a backup to make sure it works # <bucket-name> is the bucket you created in the AWS dashboard dokku postgres:backup <service> <bucket-name> # Schedule reguluar backups # The <schedule> is a crontab expression wrapped in quotation marks, # like "0 0 * * *" for every day at midnight dokku postgres:backup-schedule <service> <schedule> <bucket-name>