Skip to content

Database backups produce empty 20-byte files — cleanUpBackups() sudo find fails with empty error message #821

Open

Description

@jacmaes

CloudPanel version(s) affected

2.5.4

Description

The nightly database backup job produces empty files for every database on the host. Each .sql.gz is exactly 20 bytes — a valid gzip header wrapping a zero-byte payload:

1f8b 0800 0000 0000 0003 0300 0000 0000 0000 0000

i.e. gzip compressing empty input. No database is backed up, and nothing is reported in the UI or in any log.

The failure is not in mysqldump. Running the backup command manually surfaces the real error, which originates in cleanUpBackups():

Command " : /usr/bin/sudo /usr/bin/find /home/<user>/backups/databases -mindepth 1 -type d -mtime +7 -exec rm -rf {} \; > /dev/null 2>&1" failed, error message: ,
#0 CommandExecutor->execute()
#1 DatabaseBackupCommand->cleanUpBackups()
#2 DatabaseBackupCommand->createDatabaseDump()

Two things stand out:

  1. The failing command is the retention cleanup (sudo find … -mtime +7 -exec rm -rf), not the dump itself.
  2. error message: , is empty — because the command redirects its own stderr to /dev/null, so the actual cause is discarded before it can be reported. This makes the failure undiagnosable from the logs.

Scope: this affects every user on the host, not one site. The error log lists all 17 accounts in my case.

The databases themselves are fine — dumping them manually succeeds with exit 0 and full output.

How to reproduce

  1. On a host with CloudPanel 2.5.4, wait for the nightly job (/etc/cron.d/clp, 15 3 * * *) or run it directly as root:

    su -s /bin/bash -c '/usr/bin/clpctl db:backup' clp
    
  2. Observe the Command " : /usr/bin/sudo /usr/bin/find …" failed, error message: , output.

  3. Check the resulting file:

    ls -l /home/<user>/backups/databases/<db>/$(date +%F)/
    

    Every file is 20 bytes. zcat returns nothing.

  4. Confirm the database itself is dumpable, proving the fault is in the cleanup step rather than the dump:

    mysqldump -hlocalhost -u<user> -p<pass> <db> --skip-comments | wc -c
    

    This returns the full size and exit 0.

Possible Solution

  1. Do not discard the error. The > /dev/null 2>&1 on the cleanup command means the failure reason is thrown away and then reported as an empty string. Capturing stderr (or logging it before discarding) would make this class of failure diagnosable.

  2. Make the cleanup non-fatal. A failure to prune old backups should not prevent the database dump from being written. Currently cleanUpBackups() is called from createDatabaseDump(), so a cleanup error appears to abort the whole operation.

  3. Consider whether sudo is required for the cleanup at all, given the files are owned by the site user.

Additional Context

Additional Context

No response

Activity

  1. jacmaes commented on Oct 16, 2026

    @jacmaes
    Author

    Update — correcting one claim, and adding new evidence

    Two corrections and some new data after further investigation.

    1. The sudo timing in my original report was wrong — please disregard it

    I noted that sudo was updated 2026-10-06 and that failures began 2026-10-07. That was a misreading on my part: the binary mtime is the build date, not the install date. The changelog and the binaries share the same timestamp:

    changelog build date:   06 Oct 2026 10:05:40
    /usr/bin/sudo mtime:    06 Oct 2026 10:05:40
    /usr/bin/sudoedit:      06 Oct 2026 10:05:40
    /usr/bin/sudoreplay:    06 Oct 2026 10:05:40
    

    The actual install was:

    2026-10-14 13:01:53  upgrade sudo:amd64 1.9.9-1ubuntu2.6 -> 1.9.9-1ubuntu2.7
    2026-10-14 13:04:01  configure sudo:amd64 1.9.9-1ubuntu2.7
    

    The empty backups began 2026-10-07, a week before that upgrade. So the sudo version is not the cause. Apologies for the noise.

    2. Retention appears to be working — the cleanUpBackups() error may be spurious

    I reported the sudo find ... -mtime +7 -exec rm -rf failure as the cause. But checking the directories themselves:

    Host Database Directories Range Older than 7 days
    US spain*** 9 10-08 to 10-16 1
    US spaincu*** 8 10-09 to 10-16 0
    EU danielcasa*** 8 10-09 to 10-16 0

    Old directories are being pruned. So the logged failure does not prevent cleanup from working, and it is probably not what produces the empty files. The empty error message: , is still a genuine diagnosability problem worth fixing, but I no longer believe it is the root cause.

    3. New: the same CloudPanel version works on another host

    Host A (broken) Host B (working)
    CloudPanel 2.5.4-2+clp-jammy 2.5.4-2+clp-jammy
    Ubuntu 22.04.5 LTS 22.04.5 LTS
    Backups 17 files, all 20 bytes 8 files, ~169 KB each

    Host B's most recent backup succeeded today: 169,124 bytes, decompressing to 894,581 bytes. So this appears to be host-specific rather than a universal defect in 2.5.4.

    4. Workaround

    For anyone else hitting this, an independent mysqldump cron running as the site user works around it entirely, without touching CloudPanel:

    30 4 * * * mysqldump --single-transaction --no-tablespaces <db> | gzip > ~/backups/manual/<db>-$(date +\%F).sql.gz
    

    5. Root cause?

    CloudPanel's master credential fails with ERROR 1045
    The site's own user dumps fine — proving the database is healthy
    The failure is silent because the error is discarded
    Suggested fix: validate the master credential before dumping, and surface the error rather than swallowing it

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions