PMM-7 Dev env for MySQL backups.#5407
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3 #5407 +/- ##
=======================================
Coverage 43.22% 43.22%
=======================================
Files 413 413
Lines 42279 42279
=======================================
Hits 18277 18277
Misses 22134 22134
Partials 1868 1868
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a local, single-container Docker Compose development environment to speed up testing PMM MySQL physical backups by running PMM Server (with builtin pmm-agent), mysqld, and XtraBackup on the same host/container.
Changes:
- Introduces a
dev/mysql-backup-composeCompose stack with a custom PMM Server image that installs Percona Server for MySQL 8.4 and Percona XtraBackup 8.4. - Adds supervisord programs plus scripts to start
mysqldand auto-register amysql-backupservice in PMM. - Adds a Makefile and README to standardize local usage (
make env-up/env-down, status/logs/register helpers).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| dev/mysql-backup-compose/docker-compose.yml | Compose service definition for the local PMM+MySQL backup environment. |
| dev/mysql-backup-compose/Dockerfile | Builds a PMM Server-derived image with MySQL/XtraBackup/qpress installed and supervisord config added. |
| dev/mysql-backup-compose/supervisord-mysql.ini | Adds supervisord programs for mysqld and MySQL service auto-registration. |
| dev/mysql-backup-compose/start-mysqld.sh | Initializes (if needed) and runs mysqld with local socket + binlog/perfschema. |
| dev/mysql-backup-compose/register-mysql.sh | Waits for PMM + agent + MySQL, bootstraps DB users, and registers the MySQL service in PMM. |
| dev/mysql-backup-compose/mysql-init.sql | Creates/grants the pmm MySQL user for monitoring/backup. |
| dev/mysql-backup-compose/Makefile | Developer commands to bring the environment up/down and inspect logs/status. |
| dev/mysql-backup-compose/README.md | Usage documentation and version/override notes for the dev environment. |
Comments suppressed due to low confidence (1)
dev/mysql-backup-compose/register-mysql.sh:57
- This bootstrap sets the password for
root@localhost, but it connects using TCP to127.0.0.1(mysql -h 127.0.0.1 -uroot ...). If the only root account isroot@localhost, the connection used here may not be permitted, causing initialization to fail. Use socket-based connections for bootstrap (--protocol=socket --socket=...) and/or also update/create a root account that matches the connection host.
bootstrap_mysql_users() {
if [ -f "${STATE_DIR}/.pmm-backup-initialized" ] && [ ! -f "${STATE_DIR}/.pmm-backup-root-password-set" ]; then
log "setting MySQL root password"
mysql -h 127.0.0.1 -uroot <<-EOSQL
ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}';
FLUSH PRIVILEGES;
EOSQL
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| wait_for_mysqld() { | ||
| log "waiting for mysqld..." | ||
| local attempt=0 | ||
| until mysqladmin ping -h 127.0.0.1 -uroot --silent 2>/dev/null \ | ||
| || mysqladmin ping -h 127.0.0.1 -uroot -p"${MYSQL_ROOT_PASSWORD}" --silent 2>/dev/null; do |
| if docker exec $(CONTAINER) /usr/local/percona/pmm/bin/pmm-admin list \ | ||
| --server-url="https://$${PMM_ADMIN_USER:-admin}:$${PMM_ADMIN_PASSWORD:-admin}@127.0.0.1:8443/" \ | ||
| --server-insecure-tls 2>/dev/null | grep -q 'mysql-backup'; then \ |
| @docker exec $(CONTAINER) sh -c 'mysqladmin ping -h 127.0.0.1 -uroot -p"$${MYSQL_ROOT_PASSWORD:-secret}" --silent' 2>/dev/null \ | ||
| && echo "mysqld: ready" || echo "mysqld: not ready" |
| env-logs: ## Tail registration and mysqld logs | ||
| docker exec $(CONTAINER) sh -c 'tail -n 50 /srv/logs/mysql-backup-register.log /srv/logs/mysqld-backup-dev.log 2>/dev/null' || true |
| register_mysql_service() { | ||
| if "${PMM_ADMIN}" list --server-url="${PMM_SERVER_URL}" --server-insecure-tls 2>/dev/null | grep -q 'mysql-backup'; then | ||
| log "mysql-backup service already registered" | ||
| return 0 | ||
| fi | ||
|
|
||
| log "registering mysql-backup service" | ||
| local attempt=0 | ||
| while [ "${attempt}" -lt 30 ]; do | ||
| if "${PMM_ADMIN}" add mysql mysql-backup 127.0.0.1:3306 \ |
| && percona-release setup ps84lts \ | ||
| && percona-release enable pxb-84-lts release \ | ||
| && percona-release enable tools release \ | ||
| && dnf install -y "percona-server-server-${MYSQL_SERVER_RPM_VERSION}" "percona-xtrabackup-84-${XTRABACKUP_RPM_VERSION}" qpress \ |
There was a problem hiding this comment.
Installing PS and PXB to the PMM Server is a questionable design decision. It would be much cleaner to have a separate container for these two.
Even though I understand that this is being done for testing purposes, however this deployment doesn't seem to be close to any real-life scenario.
If we have to install the client as well to meet the deployment requirement, we can use the tarball from the feature build.
This will allow to reuse the same Docker compose file elsewhere.
PMM-7
As side effect during working on #5395 I created dev/mysql-backup-compose because testing MySQL physical backups requires mysqld, xtrabackup on the same host as pmm-agent. The compose setup builds a PMM Server image with MySQL and XtraBackup installed locally. This is reducing time to setup backups for dev significantly. Probably not clean and best solution, but I think it is better to have something than nothing. QA also does not have any setup and they doing everything manually every time.
Usage:
make env-up
make env-down