Here’s a handy docs page to be familiar with if/when disaster strikes your Moodle. Whether it’s cleaning up spam profiles or fixing hacked files for your installation this is a great place to start; especially the section about Prevention.
http://docs.moodle.org/20/en/Hacked_site_recovery
A few of the suggestions for prevention:
- update to the best/most recent stable version
- understand user permissions
- get a good server administrator
- know your hosting help line!
- Most importantly, don’t wait until something happens to you!