First of all, thank you both Ken and Emma for your suggestions. I appreciate the help.
I tried enabling the Legacy File repository but the issue persisted. I was about to try Ken's answer but I found out finally what was causing the issue!
Recently we have added the "2.0 backup and restore" functionality no a custom plugin that we have and there was a mistake in it. One regex statement wasn't written correctly and it caused all those errors in the backups. Once I fixed that, everything started working again!
I'll probably try now that I've recovered the courses to 3.3, removing its legacy contents so it is up to date with the current moodle implementation.
Thanks both of you for your help! I hope somebody can benefit from this in the future.