Good use of TIME feature in this query
You could make it a little faster by only retrieving columns that are required (mdl_log has some columns you probably don't need), and you could alter the INTERVAL from 6 MONTH to 1 MONTH or EVEN 1 WEEK and export that data.
Using something like MySQL Workbench might be a good way to approach this task.