Scheduled Backups with strtfime substitution do not delete older backups

When creating scheduled backups that use strftime style substitutions, the delete old backups functionality does not function properly. I am admittedly unsure if this is a feature request or a bug, however, I personally consider it a bug since a feature essentially fails to function as one would expect given the options presented to the user.

Essentially, if the path specified is something like /backup/%Y-%m-%d which we use because we want to backup each virtual server individually for the ability to more granularly restore if necessary. When using this style path, the delete older backup function, only checks the current "substituted" directory path, which means that older backups are never deleted from a different day.

For example, if a backup was made on 3/24/2021 and the delete older than is set to 5 days, and after a few days of backups run, a backup is performed on 3/30/2021, the backup made on 3/24/2021 should now be deleted based on the configured settings.

However, the virtualmin backup routine that runs on 3/30/2021 only checks the /backup/2021-03-30 path for older backups which results in none being found. Therefore, older backups never get deleted and the potential to fill up the drive exists without manual intervention.

When using strftime substitution, the Virtualmin routine should check all substituted paths that would have been used over the previous periods. I understand that the potential issue may be, how far back and how many paths do you check because of the potential number of configuration options may make this impossible to know. IE, if someone has monthly backups configured, but a setting for delete backups older than 5 days, should Virtualmin go back 30 days to check this path and remove it? I believe that the answer is that for strftime substitution to work properly, a user almost certainly needs to use the "create destination directory" option as well. I would propose that anytime during a backup routine that Virtualmin needs to create a destination directory, the directory path that was created should be stored in the database and / or a config file somewhere so that a future scheduled backup routine can reference the created paths and check them for old backup files. If after checking for old backup files, the directory is empty, the directory should be deleted as well and the reference to it removed from the database / config file to avoid checking that the path again in the future. Finally, for completeness, the routine should also check for the existence of the path in the first (in case a user manually removes a backup) and remove it from the database / config file if it doesn't exist.

Status: 
Active
Virtualmin version: 
6.14
Webmin version: 
1.962

Comments

Ilia's picture
Submitted by Ilia on Fri, 04/02/2021 - 18:56

Hi,

Thanks for the heads up.

Is this still happening to be an issue with the latest Webmin 1.973 and Virtualmin 6.16?

Are you backing up to a local directory, to a remote server, or to Amazon S3?

Also, are you backing up to separate files per domain under that directory?

I am backing up to a local directory.

/backup/%Y-%m-%d as mentioned in my original post.

Separate files per domain. If I was only doing a single file, then I wouldn't need the "create destination directory" option which I think is what partially introduces the issue. The strftime substitution would be done as a filename instead of a directory name and I think everything would work fine.

Installing the latest release now, so I will report back in a couple days and let you know if it is still an issue.

OK, please let us know if this is still happening