Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# MySQL backup container for DB Operator

Small docker container for creating a backup of a musql database and uploading it to an external storage using rclone.

Every backup is uploaded twice, once with a **timestamp** and once as **latest**. So you can always download the latest backup.

There is no clean-up logic, please take care of old backups using external tools, for example bucket retention policies.

## How to restore

You need to unzip the backup file and restore it with `mysql` cli:
```shell
$ gzip -dk <Path to the backup archive>
$ mysql -u <Admin user> --password=<Admin password> -h <Database host> -P <Database Port> --database working_namespace_mysql < <Path to backup>
```

## How to use

This container is supposed to be used by the DB Operator for setting up backup CronJobs.

To backup a mysql/mariadb database using this container you need to pass env variables for `mariadb-dump` and for `rclone`:

**mariadb-dump** variables:

- **DB_NAME**: A name of a database to back up
- **DB_PORT**: A port on which database is listening
- **DB_HOST**: A database server host
- **DB_PASSWORD_FILE**: A path to a file with a database password (file must be mounted to the container)
- **DB_USER**: User that should perform the backup

**rclone** variables:

- **STORAGE_BUCKET**: A name of a bucket/directory that should be used for uploading the backup

For the rest, please check here: <https://rclone.org/docs/#environment-variables>.

The backend name is hardcoded to 'storage', so your env vars should be prefixed by `RCLONE_CONFIG_STORAGE_`

2 changes: 1 addition & 1 deletion build/set_image_metadata
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ org.opencontainers.image.revision=$GITHUB_SHA
org.opencontainers.image.vendor=$GITHUB_REPOSITORY_OWNER
org.opencontainers.image.license=GNU GENERAL PUBLIC LICENSE v3
org.opencontainers.image.title=$GITHUB_REPOSITORY
org.opencontainers.image.description=Backup databases using pg_dump and upload backups using rclone
org.opencontainers.image.description=Backup databases using mariadb-dump and upload backups using rclone
EOF
)

Expand Down