Which tables are safe to be truncated ?

Which tables are safe to be truncated ?

by Antonello Lobianco -
Number of replies: 2

Hello to everyone. For the purposes of dumping a Moodle db for backups, which tables can be exported as structure only (that is, they are cache tables safe to be truncated) ?

I don't want to export cached data as the backups are to be kept in a revision control system.

Also, this page, list 4 cache directories in moodledata safe to be ignored during a backup, namelly 'cache', 'lang', 'sessions' and 'temp'.

Can you confirm me that in case they are missing they would be automatically recreated without consequences (aside performance of course) ? What about 'localcache', 'temp' and 'trashdir' directories ?

Thank you,

  Antonello

Average of ratings: -
In reply to Antonello Lobianco

Re: Which tables are safe to be truncated ?

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

AFAIR there is a possible condition race when deleting the files, so it may happen that a file is in trashdir while it is still in use - so it's not 100% reliable to just ignore trashdir. It's pretty unlikely though this will affect you if you do the backup when the site is not used (e.g. at night).

I think that localcache and temp should be safe to ignore.

Weren't overriden strings stored under moodledata/lang? In such a case this one *should* be backed up.


Tomek