Skip to content

PMM-7 Dev env for MySQL backups.#5407

Open
JiriCtvrtka wants to merge 1 commit into
v3from
PMM-7-dev-env-for-backups
Open

PMM-7 Dev env for MySQL backups.#5407
JiriCtvrtka wants to merge 1 commit into
v3from
PMM-7-dev-env-for-backups

Conversation

@JiriCtvrtka
Copy link
Copy Markdown
Contributor

@JiriCtvrtka JiriCtvrtka commented May 22, 2026

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.22%. Comparing base (7fccd1e) to head (c450ef4).
⚠️ Report is 1 commits behind head on v3.

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           
Flag Coverage Δ
admin 34.94% <ø> (ø)
agent 49.16% <ø> (ø)
managed 42.34% <ø> (ø)
vmproxy 72.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JiriCtvrtka JiriCtvrtka marked this pull request as ready for review May 22, 2026 12:01
@JiriCtvrtka JiriCtvrtka requested a review from a team as a code owner May 22, 2026 12:01
@JiriCtvrtka JiriCtvrtka requested review from 4nte, ademidoff, Copilot and maxkondr and removed request for a team May 22, 2026 12:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-compose Compose 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 mysqld and auto-register a mysql-backup service 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 to 127.0.0.1 (mysql -h 127.0.0.1 -uroot ...). If the only root account is root@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.

Comment on lines +37 to +41
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
Comment on lines +34 to +36
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 \
Comment on lines +50 to +51
@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"
Comment on lines +58 to +59
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
Comment on lines +68 to +77
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 \
Copy link
Copy Markdown
Member

@ademidoff ademidoff May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants