features
downloads
screenshots
contribute
contact
references
faq
help

Auto Delete of Old Backups Not Working

maxuser
Posted: 2025-06-25 08:41

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?

backup_dev
Posted: 2025-06-25 09:12

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/{}
phpsys_admin
Posted: 2025-06-25 09:47

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.

maxuser
Posted: 2025-06-25 10:03

Got it. I added the cleanup line at the end of cron.php and now it’s removing the oldest files as expected. Thanks!

Issue: Old Backups Not Being Automatically Deleted

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.

Possible Cause: GUI Setting Not Enforced Automatically

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.

Recommended Solution: Manual Cleanup via Script

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.

Additional Tip: Check File Permissions and User Context

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.

Confirmed Fix from Users

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.