Universal Database Backup
2.5K
Because I want :
PLEASE . REMEMBER . TO . TEST . YOUR . BACKUPS . REGULARLY .
You can mount the directory /data. The directory contains 2 subdirectories :
/data/backup Directory where is saved the backup files./data/restore (for mysql and mongo only) copy file from backup in this directory and the backup is imported in database.All variables can used with docker secrets, simply append _FILE of the variable name, and set the secret file path. i.e. :
BACKUP_PASS_FILE and set to /run/secrets/BACKUP_PASSBACKUP_NAME_FORMAT: (OPTIONNAL) Name format of backup (without extension). It use date format. Default is +%Y-%m-%d.%Hh%M.%SBACKUP_CRON_TIME: (OPTIONNAL) Cron schedule, default is 0 0 * * *BACKUP_RUN_ON_START: (OPTIONNAL) Run first backup when container start if this env is definedBACKUP_RUN_ON_START_DELAY: (OPTIONNAL) Delay in seconds if run on start is set. Default is 20BACKUP_DRIVER: Backup type, must be mongoBACKUP_HOST: Mongo hostBACKUP_PORT: Mongo portBACKUP_USER: Mongo usernameBACKUP_PASS: Mongo passwordBACKUP_DB: Mongo databaseBACKUP_EXTRA_OPTS: Extra optionsBACKUP_DRIVER: Backup type, must be mysqlBACKUP_HOST: MySQL hostBACKUP_PORT: MySQL portBACKUP_USER: MySQL usernameBACKUP_PASS: MySQL passwordBACKUP_DB: MySQL database (optionnal)BACKUP_EXTRA_OPTS: Extra options (you can use --all-databases)BACKUP_DRIVER: Backup type, must be redisBACKUP_HOST: Redis hostBACKUP_PORT: Redis portBACKUP_PASS: Redis passwordBACKUP_EXTRA_OPTS: Extra optionsYou can contribute ;)
See rotate-backups for more details
BACKUP_ROTATE_MINUTELY: NumberBACKUP_ROTATE_HOURLY: NumberBACKUP_ROTATE_DAILY: NumberBACKUP_ROTATE_WEEKLY: NumberBACKUP_ROTATE_MONTHLY: NumberBACKUP_ROTATE_YEARLY: NumberBACKUP_ROTATE_OPTS: Add more optionsSend alert if backup file is not created, the size of last backup is greater a value or backup size is less a value.
BACKUP_ALERT_NAME: Name of backup, i.e. : My project - Mongo BackupBACKUP_ALERT_IF_THE_SIZE_OF_LAST_BACKUP_GREATER_THAN: Alert from diff size with last backup is lower. See numfmt format. Default no alertBACKUP_ALERT_IF_THE_BACKUP_SIZE_IS_SMALLER_THAN: If the size of backup is smaller of this value. See numfmt format. Default no alert.Availables transports :
BACKUP_ALERT: value must be slackBACKUP_SLACK_WEBHOOK_URL: i.e https://hooks.slack.com/services/XXX/YYYY/ZZZZBACKUP_ALERT: value must be mailBACKUP_MAIL_FROM: [email protected]BACKUP_MAIL_HOST: smtp.host.comBACKUP_MAIL_PASS: mail passwordBACKUP_MAIL_TO: [email protected]BACKUP_MAIL_USER: usermailBACKUP_S3_ACCESS_KEYBACKUP_S3_HOST_BASEBACKUP_S3_HOST_BUCKETBACKUP_S3_OPS: Additional options, you can (should?) use --delete-removedBACKUP_S3_PATH: i.e.: s3://mys3/my-projet-mongo-backup/BACKUP_S3_REGION: default us-west-1BACKUP_S3_SECRET_KEYBACKUP_S3_USE_HTTPS: default TrueSimply copy zipped file in data/restore directory. A cron try to restore a database all minutes.
Host port 8042 and 9000 is required for test
git clone https://github.com/apoutchika/backupdocker-compose up./fixtures.sh for create datas in DBdata/backups directory or on S3You can see alert mail on http://localhost:8042/, and S3 data on http://localhost:9000/ (access is s3\_key and s3\_secret).
The backup is created all minutes.
Test restore :
docker-compose downsudo rm -rf ./data/{mongo,mysql,redis}/*./data/redis/dump.rdbdocker-compose up --force-recreate./data/backups/mongo/backup/ to ./data/backups/mongo/restore/ for MongoDB./data/backups/mysql/backup/ to ./data/backups/mysql/restore/ for MySQLTest alerts :
docker-compose exec backup-mysql bash -c "truncate -s 3M /data/backup/fakeBigBackup.gz"docker-compose exec backup-mongo bash -c "truncate -s 3M /data/backup/fakeBigBackup.gz"docker-compose exec backup-redis bash -c "truncate -s 3M /data/backup/fakeBigBackup.gz"./clean.sh. After the next backup, see alerts on webmaildocker-compose stop mysql mongo redis. After, the next backup, see alerts on webmailContent type
Image
Digest
sha256:582997f9e…
Size
273 MB
Last updated
about 3 years ago
docker pull apoutchika/backup