Fill missing parts and add backup/restore

Fill missing functions. Add backup/restore. Change TABs to spaces to
conform Moodle coding style.