Restore corrupt database after nightly purge

No way. The repack destroys my database.
In September, I decided to start fresh with a clean database, setting the purge to 90 days.
Until today, everything was fine, and the database was only 4GB. Even the repack, scheduled every second Sunday of the month, worked smoothly, and I noticed the database size decreasing significantly.

However, last night (second sunday of december), it got corrupted again.
I tried downloading the file, repairing it with SQLite, and re-uploading it after stopping the core. Upon restarting, the freshly uploaded database is immediately marked as corrupted, and HA starts with a new database.

Even if I manually start the purge action by selecting only

action: recorder.purge
data:
  repack: true

the database gets corrupted.

For now, I’ve restored yesterday’s backup, but I’m sure I’ll face the same issue again in a month.

Could the problem be related to the 90-day data retention setting? I could try reducing it, but even so, the next purge will likely delete the entire database.

Any ideas?