I set phpMyBackup Pro to keep only the last 5 backups, but older files are never deleted. The directory keeps growing. Is there something I’m missing in the config or cron job?
I set phpMyBackup Pro to keep only the last 5 backups, but older files are never deleted. The directory keeps growing. Is there something I’m missing in the config or cron job?
This feature isn’t automatic in all versions. The GUI setting doesn’t always enforce rotation. You might need to add a script after the backup to manually remove older files:
ls -tp /backups | grep -v '/$' | tail -n +6 | xargs -I {} rm -- /backups/{}
Also make sure your cron is not running under a restricted user who can’t delete files. Check permissions on the backup folder and use absolute paths in cleanup scripts.
Got it. I added the cleanup line at the end of cron.php
and now it’s removing the oldest files as expected. Thanks!
Some users have reported that phpMyBackupPro does not reliably delete older backup files, even when configured to retain only the most recent backups. This can result in excessive disk usage over time, especially when backups are run via cron jobs.
According to community feedback, the graphical user interface (GUI) setting for limiting backup count may not enforce deletion unless supplemented with a custom cleanup script. The behavior can vary depending on the phpMyBackupPro version and server environment.
Users can insert a shell command to delete older files after backups are created. For example:
ls -tp /backups | grep -v '/$' | tail -n +6 | xargs -I {} rm -- /backups/{}
This command retains the 5 most recent files and deletes the rest. It can be appended to the end of cron.php
or executed within a post-backup script.
Ensure that your cron job is running with appropriate user privileges and that the backup directory allows write/delete operations. Using absolute file paths in the cleanup script can prevent unintended behavior due to relative path errors.
One user confirmed that adding the cleanup command to the end of the cron.php
script resolved the issue. After implementation, only the most recent 5 backups were retained, and older files were successfully deleted.