View Single Post
Old 3rd August 2011, 01:17
snowfly snowfly is offline
Join Date: Jul 2006
Posts: 93
Thanks: 0
Thanked 7 Times in 5 Posts
Default Old website backups not deleted

I have noticed that if we change the backup options for a website in ISPConfig, the older backups are not deleted.
Running ISPConfig

This is when you change the copies of backups to keep from a larger number to a smaller number.

The effect of this is when we select a smaller number of backup copies to keep, we expect disk space usage to drop, this does not happen, as all backup copies are still kept.

Take this example:
Backup interval: daily
Backup copies: 2

In the /var/backup/webX/ folder we then get 2 backups:

Then we change backup copies = 1

The next day, the /var/backup/webX/ folder still has 2 backups (not 1):

The file is dated from 2 days ago.

So it appears the ispconfig cron_daily.php script does not take into account deleting older copies of backups.

Relevant code in /usr/local/ispconfig/server/cron_daily.php starts on line 430:
// Rename or remove old backups
                                $backup_copies = intval($rec['backup_copies']);

                                if(is_file($web_backup_dir.'/web.'.$backup_copies.'.zip')) unlink($web_backup_dir.'/web.'.$backup_copies.'.zip');

                                for($n = $backup_copies - 1; $n >= 1; $n--) {
                                        if(is_file($web_backup_dir.'/web.'.$n.'.zip')) {
Should there also be some code that deletes any older backup copies that are greater than $backup_copies ($backup_copies +1)?
From when the user decreases the number of backup_copies to keep.

e.g. something like this maybe:
// delete any older backup copies that previously existed
// loop through $backup_copies+1 up to 10, check if file exists, then delete
for ($n = $backup_copies+1; $n <= 10; $n++) {
Would something like the above work?

Last edited by snowfly; 3rd August 2011 at 01:20.
Reply With Quote
Sponsored Links