Cleanup soft deleted files and entries

Hi there,

Im looking at deleting not used and soft deleted files.

For example we have some records (module invoices) where the pdf attached to the record can be regenarated many times, each generation is pushing a new pdf onto the system and links the fileid to the record. so after 3 regeneration of invoices there are 2 not used pdf in the system but there isnt a trace at the database for these files.

also i would love to delete all soft-deleted records and files after a certain period of time. are there some scripts which i could use, or do you have a starting point for writing a script for that?

ive found the sql snippets which give me a good start for deleting soft deleted records in db.

If im not mistaken i would have to loop through every file on filesystem data dir and do a db query if i can find that fileid anywhere in the db, if not i can safly delete the files and preview files on filesystem. is this correct, or is there a faster way around?

Best regards

Hi @nabl ,

we do not have any internal mechanism for cleanup, though it would be a nice-to-have.

What I would suggest is going devop level and create a crontab script that runs daily which would run an sql to fetch all the pdf metadata and then do the cleanup on the fs level.

When it comes to deleting the soft-deleted records, I would take the same approach, or I would research if it’s possible to schedule a db procedure (depends on your db flavor).