Databases 5 min read

MySQL Backup Failure Caused by Duplicate Cron Jobs and How to Fix It

The article explains how a MySQL backup using xtrabackup failed due to two concurrently running cron daemons launching the same backup script, resulting in corrupted compressed files, and provides practical solutions such as using flock, regular restore drills, and monitoring crond processes.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
MySQL Backup Failure Caused by Duplicate Cron Jobs and How to Fix It

Background: An online MySQL instance planned to upgrade to 8.0, and a test environment was built from a daily xtrabackup full backup that is compressed to about 300 GB; decompression repeatedly fails with gzip errors.

Fault analysis: The backup script, executed by crontab, streams xtrabackup output to gzip and writes to xxx.tar.gz . Although the script reports success, the cron logs show that the same job is launched twice at the same minute, and two crond processes are running concurrently. Both processes write to the same archive, causing data overlap and corruption.

Root cause: The system had two crond daemons running, so each triggered the backup script simultaneously. After stopping one daemon and restarting crond , only a single process remained and the duplicate execution stopped.

Remediation: Add a file lock (e.g., flock ) to the script to ensure mutual exclusion, conduct regular backup‑restore drills, and monitor the number of crond processes, alerting when it differs from one.

Keywords: #backup failure #cron job.

linuxMySQLBackupCronxtrabackupDatabase Administration
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.