Docker Service to Backup a PostgreSQL / MySQL Database

I have written a docker service to be used for a periodically backup of a PostgreSQL Database. This container can be used to be part of a docker stack in a docker-compose.yml file.

version: '3.1' 
services:
...
backup:
image: imixs/backup
environment:
SETUP_CRON: "0 3 * * *"
BACKUP_DB_TYPE: "POSTGRESQL"
BACKUP_DB_USER: “postgres”
BACKUP_DB_PASSWORD: “xxxxxxxxxx”
BACKUP_DB_HOST: “db”
BACKUP_LOCAL_ROLLING: “5” ....

The service runs a cron job an uploads backup files automatically into a remote backup space via SFTP/SCP.

Backup MySQL

You can also use this Docker Image to backup a MySQL Database. Just change the environment variable ‘BACKUP_DB_TYPE’:

BACKUP_DB_TYPE: "MYSQL"

Of course the service also provides methods to restore the data. The Service is published on GitHub and DockerHub where you will find more details.

2 Replies to “Docker Service to Backup a PostgreSQL / MySQL Database”

  1. This is outdated and should be:

    BACKUP_DB_USER: “postgres”
    BACKUP_DB_PASSWORD: “xxxxxxxxxx”
    BACKUP_DB_HOST: “db”
    BACKUP_LOCAL_ROLLING: “5”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.