def _delete_extra_backups(self):
        exclude_states = (Backup.States.DELETING, Backup.States.DELETED, Backup.States.ERRED)
        backups_count = self.backups.exclude(state__in=exclude_states).count()
        extra_backups_count = backups_count - self.maximal_number_of_backups
        if extra_backups_count > 0:
            for backup in self.backups.order_by('created_at')[:extra_backups_count]:
                backup.start_deletion()
Deletes oldest existing backups if maximal_number_of_backups was reached
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/backup/models.py/BackupSchedule._delete_extra_backups