Backup and restore

backup_unique_code missing

Picture of Lev Abramov
backup_unique_code missing
Dear all -

this error (A required parameter (backup_unique_code) was missing) seems to have occurred several times in this year's postings - many people have reported it, but none of the threads I've been able to offers a solution. Everything ends in "Oh, good, I've solved it" without explaining how.

Could some kind soul please pick this call up and explain what's wrong and how to get rid of this annoyance?!

The error affects only SOME of the courses while others back up without a glitch.

Moodle 1.9.5 (Build: 20090520). In Notifications, there is one message that might have something to do with the error, I suspect:

Enabling the PHP setting display_errors is not recommended on production sites because some error messages may reveal sensitive information about your server.

In any case, I cannot instantly change this setting, as the server is managed by a tech support team that is extremely unsupportive (pun intended).

Looking forward to hearing some good news - like, here's what you need to do, etc.


Average of ratings: -
el quique
Re: backup_unique_code missing
hi lev,
i was the same problem, and solve this
go to menu site administrator, go server, select session handling and disable or unchek the first option: use database for session information
save changes and ready.

Average of ratings: Useful (2)
Picture of Nadav Kavalerchik
Re: backup_unique_code missing
Core developersParticularly helpful MoodlersPlugin developersTestersTranslators
i can support Enrique and say that it works fine
without the DB handling the sessions

Average of ratings: -
Picture of Lev Abramov
Re: backup_unique_code missing
Thank you folks for your help. Worked like a charm. smile

Best -

Average of ratings: -
One poor developer...
Re: backup_unique_code missing
Core developersDocumentation writersMoodle HQPlugin developersTesters

just a side note. The rationale beyond this problem uses to be that, under some DBs it's needed to adjust the maximum size of the information that can be sent, as far as it uses to default to a really small value. And backup build some in-session structures that are really big.

In any case, be noted that, while switching off DB sessions is a solution for backup & restore... the problem will happen in any insert/update going over that size. So it's highly recommended to raise such small default value!

Noticeable MySQL defaults to 1MB, so any insert/update of information bigger that that, will cause, for sure, problems, and worst of all, it uses to do it silently, cutting the information without further notice. sad

Luckily it can be adjusted by setting the max_allowed_packet variable in the my.cnf configuration file (I've it set to 50M, for example). Don't forget to restart the MySQL server after that. wink

Finally, since Moodle 1.9.7 (I think), there is one built-in system on restore that detects if something have been broken in session informing you with this message:

"Some problem happened with the restore information stored in your session. Please check your PHP memory/DB package size limits. Restore stopped."

And stopping the process before causing any further damage.

Hope this explains a bit the session thing and the problems in backup and restore.

Ciao smile
Average of ratings: Useful (1)
Picture of Arnold Lamont
Re: backup_unique_code missing

Hi Eloy,

I run my moodle site (primarily as a user/teacher) but I am not a Php or apache expert.

I can't backup and get the error mentioned (Unique code missing).

I am running Moodle 1.9.5.

(BTW, when I now tried to go to Notifications on the Site Admin within moodle, I got the following: " Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 122880 bytes) in /home/*****/public_html/moodle/lib/soap/nusoap.php on line 6149"

Might this be related? Is this server or browser related?  )

I have unchecked the first box within Moodle under server/session handling/use database for session handling, but the problem persists.

If I understand your suggestion correctly then I should change a  max_allowed_packet variable  in my.cnf.   At this stage however, you lose me. 

Question 1:  Where do I find my.cnf?  (I have access to cpanel and know I can edit files there)

Question 2:  How do I restart MySQL server thereafter?

Sorry for the low level question here.



Average of ratings: -
Picture of Alejo Becerra Diaz
Re: backup_unique_code missing

Hola, Eloy.

Could you elaborate more about other common operations in which this problem could arise?

If it is as a great problem as it seems, what do you think about putting a check on Moodle installation process for this parameter, warning users to raise the value, as it's being done with some PHP limits?

Average of ratings: -
Picture of Clark Moodler
Re: backup_unique_code missing

"A required parameter (backup_unique_code) was missing"

I've been getting this message in the process of restoring as admin - when restoring to an "existing course" - and on the page of courses to choose from to restore to - if I click on a course BEFORE the page is done loading, I get this error.

If I click on a course AFTER the page is done loading, I do not get this error.


Average of ratings: Useful (1)
Picture of Graeme Boxwell
Re: backup_unique_code missing

Clark - Thats what we have found as well. Thanks for making us aware of it. We could have spent a long time playing with settings before realising this.

Really appreciate your help on this.


Average of ratings: -