Script to backup all databases of a mariadb instance.
mariadb-backup:
env:
BACKUP_DB_HOST=mariadb
BACKUP_DB_USER=root
BACKUP_DB_PASSWORD=root
BACKUP_NUM_KEEP=7
BACKUP_FREQUENCY=1d
volumes:
- ./database-dump:/dump
- /etc/localtime:/etc/localtime:ro
depends_on:
- mariadb
/dump
(mandatory): The directory where the dump archives will be created./etc/localtime
(optional): Timezone
Variable | Description | Default value |
---|---|---|
BACKUP_DB_HOST | The host of the DB to backup | mariadb |
BACKUP_DB_USER | Username that can read all databases | root |
BACKUP_DB_PASSWORD | You guess it | root |
BACKUP_NUM_KEEP | how many backup archive can I keep? | 7 |
BACKUP_FREQUENCY | How long to wait until each backup | 1d |
BACKUP_UID | User id of produced archives | 1001 |
BACKUP_GID | Group id of produced archives | 1001 |