Ken, thanks so much for the quick reply. Below are responses to each of your suggestions, but I have not found the problem yet.
" In the courses that fail, what mods/blocks/theme etc. do they contain that other courses may not have? Any addon plugins?"
-- All the courses are the same course restored multiple times. Occasionally it fails.
" Are the plugins up to date ... any needing an update?"
-- Using only Hotpot and Essential Theme plugins, and both are current.
"In moodledata/temp/backup/ the directory used to build backups, are there:
"1. any .log files of size larger than 0? If so, they are ascii text, so see what's in them. Clues maybe."
-- Nothing there but what looks like repeating housekeeping records made by the backup script.
"2. any folders by contenthash name ... bunch of letters and numbers. Go into one of those and see what's in there ... should find xml files that are like roadmaps to the folders contained there in ... files.xml relates to files directory, etc. Is there a moodle_backup.xml present? Thatf's the main roadmap for a backup. Is there an .mbz file present by the name backup.mbz?"
-- There are many such files, some of which show as gzip files. When I download and expand one of these, I DO find moodle_backup.xml, and it shows what looks like the entire contents of the rather long course in xml.
"How about other server logs? Web service error logs ... see 'MySQL has gone aways ...' or other entries which might provide a clue?"
-- Except for logs visible through cpanel, I have not seen the server logs that apply. If I can re-create the problem, I can contact the server host to look at the log then.
"Are the courses about the same size ... ie, the .mbz file?"
-- Yes, all the restores use the same course backup file to make multiple copies of an identical course.
"Are there any php_error files in directories of code? PHP setup and the way you are running your site there could be error logs in directories where failure occurs. In backup directory of code?"
-- Can't find any in the moodle code.
"Got moosh installed? If so have you tried restoring using moosh?"
-- No. Not familiar with Moosh.
"How about backups from the command line? /moodlecode/admin/cli/ there is a backup.php script that will backup a course by the backup preferences in site admin menu and put those backups in a directory other than moodledata/filedir. Plus CLI script takes your web service out of the loop. Suggest trying a CLI backup of one of those troubled courses to see if that works without error."
-- I tried this in the browser and it won't let me run a command from there. I'll try it in Terminal when I get a chance. The puzzle is how the error displays only occasionally.
Again, many thanks, Ken. I'd keep my fingers crossed if it didn't make typing so hard.