Maintenance

🧼 Some utilities and good practices to keep your isabl instance data safe

Database backups

The cookiecutter-api comes with some handy utilities to manage postgres backups, that you can inspect in your project code directory (compose/production/postgres/maintenance):

1. To create a backup:

docker-compose -f <environment>.yml (exec |run --rm) postgres backup

2. To list/view current backups:

docker-compose -f <environment>.yml (exec |run --rm) postgres backups

3. To restore a backup:

docker-compose -f <environment>.yml (exec |run --rm) postgres restore

It's a good practice to run your backup script regularly. For example, adding it to a cron job that runs periodically (i.e. every month, or every week)

Backup to Amazon S3

After this commit in cookiecutter-api, you can store backups in the cloud in Amazon S3. You need to add these 3 environment variables in your .envs/.production/.django file:

export DJANGO_AWS_ACCESS_KEY_ID=
export DJANGO_AWS_SECRET_ACCESS_KEY=
export DJANGO_AWS_STORAGE_BUCKET_NAME=

4. Upload recursively all the database backups to your AWS S3 bucket

docker-compose -f production.yml run --rm awscli upload

5. Download a specific backup to your instance docker volume

docker-compose -f production.yml run --rm awscli download backup_2018_03_13T09_05_07.sql.gz

Learn more at cookicutter-django docs.

Last updated