Sign inSign up

raquette/docker-mysql-backup

By raquette

•Updated over 10 years ago

Backup mysql data bases to BackBlaze cloud storage

Image
0

539

raquette/docker-mysql-backup repository overview

⁠docker-mysql-backup

Container that backs up MySQL databases to Backblaze. The container overwrites the same Backblaze object every time it is run, it is recommended you turn versioning on to retain access to previous copies.

There is an existing image available on the public registry at raquette/docker-mysql-backup⁠.

⁠Backing up

To backup run once:

$ docker run -e BB_ACCOUT_ID=accountId -e BB_APPLICATION_KEY=applicationKey -e BB_BUCKET=bucket -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=root -e MYSQL_PASSWORD=password raquette/docker-mysql-backup backup

You can provide an extra argument with a specific database to backup.

To backup run periodically: : $ docker run -e BB_ACCOUT_ID=accountId -e BB_APPLICATION_KEY=applicationKey -e BB_BUCKET=bucket -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=root -e MYSQL_PASSWORD=password -e CRONTAB="* * * * *" raquette/docker-mysql-backup cron_backup

You can provide an extra argument with a specific database to backup.

⁠Restoring

To restore an existing backup run:

$ docker run -e BB_ACCOUT_ID=accountId -e BB_APPLICATION_KEY=applicationKey -e BB_BUCKET=bucket -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=root -e MYSQL_PASSWORD=password raquette/docker-mysql-backup restore

It is important to note that if this database already exists on your server, this process will drop it first. You can also provide an extra argument with a specific database to restore.

⁠Excluding Databases

You can exclude databases from backup/restore by using --exclude.

For example:

$ docker run -e BB_ACCOUT_ID=accountId -e BB_APPLICATION_KEY=applicationKey -e BB_BUCKET=bucket -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=root -e MYSQL_PASSWORD=password raquette/docker-mysql-backup --exclude=some_database,another_database restore

⁠Waiting for mysql server to run

By default the container will wait for the mysql server to be up. To disable this set the env variable WAIT_FOR_SERVER=no .

⁠Interlocks on backup and restore

By defining RESTORE_ONCE=yes you can insure the data base is only restored once. If BACKUP_AFTER_RESTORE_ONLY=yes is defined a backup will only be performed if the db was restored in the past.

⁠Configuration

The container can be customized with these environment variables:

NameDefault ValueDescription
BB_ACCOUNT_IDblankYour BackBlaze account Id
BB_APPLICATION_KEYblankYour BackBlaze application key
MYSQL_HOST127.0.0.1Address the MySQL server is accessible at
MYSQL_PORT3306Port the MySQL server is accessible on
MYSQL_USERrootUser to connect as
MYSQL_PASSWORDblankPassword to use when connecting
RESTORE_DB_CHARSETutf8Which charset to recreate the database with
RESTORE_DB_COLLATIONutf8_binWhich collation to recreate the database with
BB_BUCKETblankThe bucket to write the backup to
BB_PATHblankThe path within the bucket
CRONTAB* * * * *crontab schedule
WAIT_FOR_SERVERyeswait for server connect to be ready [yes,no]
RESTORE_ONCEyesonly restore if there is no previous restore
BACKUP_AFTER_RESTORE_ONLYyesonly backup if db was previously restored

Tag summary

Content type

Image

Digest

Size

87.2 MB

Last updated

over 10 years ago

docker pull raquette/docker-mysql-backup