Backup and restore

 
 
Picture of Pauline McNamara
error: Could not restore modules
 
Hello all,

I've created a course backup from a Moodle 1.9.3 installation. I've tried to restore the course (creating a new course) on a Moodle 1.9.4, a Moodle4Mac installed on my Macbook Pro for testing.

Each time an error is displayed during the module part:

Creating course modules:
Resource "Course Overview"
Could not restore modules!


The restore continues through to "Closing the Restorelog.html file", but then at the end it says, "An error occured and the restore could not be completed."

Any tips about what might be hanging up the restore?

Thanks
Pauline
 
Average of ratings:Useful (1)
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Still haven't found out why this is not working, but might be able to narrow it down a bit.

Apparently none of the web pages we created in Moodle are being included in the course backup. A backup that someone else made of the same course had the same problem: They restored our course but all the web pages were missing. (I was not able to restore. It stopped each time a web page came up in the restore.)

Any reason why no web pages would get included in the backup? I'm doing a backup of all (without user data).

Thanks for any tips,
Pauline
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Still stuck on this, back with more specific info.

This happens with different course's backup, also at the Creating course modules part. I'm using a backup from a Moodle 1.9.3 installation at our institution and trying to restore to a local install on my Mac. The problem has occurred also on a sandbox Moodle on the institution's server.


Any clues? Much appreciate any help.


Thanks,
Pauline

Here's what gets displayed during the failed restore process:

Course restore: sicherung-skrips_scientific_writing-20090311-1643.zip

  • Creating new course
    • SkriPS - Scientific Writing Practice copy 3 (SkriPS_Scientific_Writing_3)
    • Category: Miscellaneous
  • Creating the Restorelog.html in the course backup folder
  • Creating groups
  • Creating sections
  • Creating categories and questions
  • Copying course files. . . . . . . . . . . . . . . . .
    • Files/folders: 34
  • Copying site files used in course
  • Creating scales
  • Creating events
  • Creating course modules
    • Resource "Writing Lab Overview Instructions"
    • Resource "Guidelines for Writing Various Types of Papers"
    • Resource "Sample Texts"
    • Resource "Student Examples"
    • Resource "Mind Mapping to Generate Ideas"
    Could not restore modules!
  • Creating roles definitions
  • Creating course level role assignments and overrides
  • Creating module level role assignments and overrides
  • Creating block level role assignments and overrides
  • Creating user level role assignments and overrides
  • Closing the Restorelog.html file.

An error has occurred and the restore could not be completed!





 
Average of ratings: -
Picture of Fredrik Ndjurumana
Re: error: Could not restore modules
 
Hi,
I got the same problem when i try to restore a course. I upgraded my moodle site from 1.8.5+ to 1.9.4+.

PLEASE HELP US!!!!!

 
Average of ratings: -
Picture of Glenys Hanson
Re: error: Could not restore modules
 
Hello,

I also have the same problem restoring from Moodle 1.9.4. (online) to 1.9.4 (local PC) with the same error message that Pauline shows.

I've discovered that if I restore the course locally without the user data it restores successfully. However, the user data is essential to what I want to do.

I have added a Word file with screencaptures of the settings I used and the error message.

I'll continue experimenting but help would be appreciated.

Cheers,
Glenys
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Hi Glenys, thanks for the info. I tried again using the settings that you show. (I think the only difference to mine was the yes for user files.) Still no go. It stops at creating the course modules. A course copy is created, the web page resources are listed as a link on the topic page, but they don't display their names and the links all lead to an error: "Course Module ID was incorrect".

Yet more info on the backup, taken from what is displayed at the beginning of the restore:

Moodle Version: 1.9.4 (Build: 20090128) (2007101540)
Backup Version: 1.9.3 (2008030301)


I'm restoring (or trying) to a local Moodle version 1.9.4+ (Build: 20090207).

Plodding on...

Thanks for any clues,
Pauline


 
Average of ratings: -
Picture of Glenys Hanson
Re: error: Could not restore modules
 
Hi Pauline and everyone,

I've discovered I can restore the course if I include all the user data except the user data for forums (just what I need to have, of course).
Is this the same for you, Pauline?

I have rather a lot of forums, so it'll take me a while to find out if it's just one that's causing the problem.

The course itself is accessible here Apprendre Moodle, if anyone knowlegeable would be willing to to take a look.

Cheers,
Glenys




 
Average of ratings: -
Me in Phnom Penh, November 2008
Re: error: Could not restore modules
 
Hello

I am also having this problem restoring old backups from various versions of Moodle to 1.9.4. Exactly the same symptoms.

If anyone monitors this thread I can provide access to the site in question.

Any help would be greatly appreciated.

Richard Jones
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Thanks Glenys. Do you mean that you do a backup with all user data, but then do the restore without the user data for forums?

I just tried doing the backup with user data except for the forums and the restore balked again at creating course modules: "Could not restore modules!". Alas.

Guess I'll try some different combinations of data included and see if I have any success. It *is* encouraging to know that you got a restore to work to completion, even if it's not exactly as you'd hoped.

Anyone else with any clues?

Thanks much!
Pauline
 
Average of ratings: -
Picture of Glenys Hanson
Re: error: Could not restore modules
 
Hi Pauline,

Yes, I do mean I do a backup with all user data but then restore without the user data for fourms.

As we don't seem to be getting any answers from developers here, I'll put something in the tracker tomorrow: that's where the big boys hang out. wink

I'm always a bit nervous of posting things in the tracker in case I'm wasting their time with a trivial problem I've created myself, but there seem to a bunch of us with this same problem.

Cheers,
Glenys
 
Average of ratings: -
Picture of Don Hinkelman
Re: error: Could not restore modules
Group Particularly helpful Moodlers
Sorry, Glenys, I am just a little boy. Can I hang out with you girls and other little teachers, too? wink

Thanks for posting on the Moodle Tracker. Here is a workaround you might try. If you do not know what php.ini is, it is an editable file which sets defaults for your PHP on the server. Those PHP settings affect Moodle operation. If you have FTP access to your server, you can change these. If you don't, show these settings to someone who does and ask them to do it.

FYI, we found a workaround to complete Restore. But it takes 29 minutes for the restore! We changed the php settings in php.ini to allow greater memory. First, we upped it from 128MB to 512MB, but got a similar error message. Then we upped it to 1024MB and restore continued for 29 minutes before success. Normally we could restore this course with Moodle 1.6 in less than minute, so there is still some kind of bug in there [Moodle 1.8/1.9]. We also increased the execution time to allow item analysis, which now works slowly. So these are the settings we changed in php.ini:
memory_limit = 1024MB
max_execution_time = 120

Cheers,
Little Don
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Hi all, big and little alike wink

Thanks for the possible workaround Don. The Moodle installation I'm trying to restore to is local on my computer, so I do have access to php.ini.

I made those two changes, restarted the server and... alas, no luck. The restore still cannot get through "Creating course modules" and displays "Could not restore modules!" and "An error has occurred and the restore could not be completed!".

Thanks for entering this in the tracker Glenys.

Still hunting, any tips much appreciated.

Regards,
Pauline
 
Average of ratings: -
Picture of david ptasnik
Re: error: Could not restore modules
 
Where is the php.ini file? I'd like to see if that corrects my issues as well.
 
Average of ratings: -
Picture of Tamio Maeda Filho
Re: error: Could not restore modules
 
Hi Glenys,

I think we have the same backup forum issue here... i recentrly tried to restore a backup from a older version (moodle 1.8.4) to the moodle 195, but unfortunatelly for my surprise there's this message "could not restore modules"...

here's the trick:

go to your older moodle version and open this file:

MOODLE_FOLDER/backup/restorelib.php

and look for this function :

-----------------------------------------------------

//This function creates all the structures for every module in backup file
//Depending what has been selected.
function restore_create_modules($restore,$xml_file) {

global $CFG;
$status = true;
//Check it exists
if (!file_exists($xml_file)) {
$status = false;
}
//Get info from xml
if ($status) {
//info will contain the id and modtype of every module
//in backup_ids->info will be the real info (serialized)
$info = restore_read_xml_modules($restore,$xml_file);
}
//Now, if we have anything in info, we have to restore that mods
//from backup_ids (calling every mod restore function)
if ($info) {
if ($info !== true) {
if (!defined('RESTORE_SILENTLY')) {
echo '<ul>';
}
//Iterate over each module
foreach ($info as $mod) {
if (empty($restore->mods[$mod->modtype]->granular) // We don't care about per instance, i.e. restore all instances.
|| (array_key_exists($mod->id,$restore->mods[$mod->modtype]->instances)
&& !empty($restore->mods[$mod->modtype]->instances[$mod->id]->restore))) {
$modrestore = $mod->modtype."_restore_mods";
if (function_exists($modrestore)) { //Debug
$status = $status and $modrestore($mod,$restore); //bit operator & not reliable here!
} else {
//Something was wrong. Function should exist.
$status = false;
}
}
}
if (!defined('RESTORE_SILENTLY')) {
echo '</ul>';
}
}
} else {
$status = false;
}
return $status;
}

-----------------------------------------------------

okay, now you find the function, you're gonna look for your newer moodle version and replace it !

remember after restore your backup, return to the original function.



 
Average of ratings: -
Picture of Howard Miller
Re: error: Could not restore modules
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
If you have problems like this the first thing to do is to enable Debugging and try again. I expect you'll now get an error message revealing the actual problem.

We can go from there smile
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
OK, we're there. Thank you. smile

Here's what comes up, saved as html.

Thanks again, appreciate it,
Pauline
 
Average of ratings: -
Picture of Glenys Hanson
Re: error: Could not restore modules
 
Hello Don and Howard,

Thanks for coming to play with us. wink

I'm also restoring to a local version - but on PC.

I changed the php.ini:
memory_limit = 1024MB
max_execution_time = 120

but it made no difference.

I downloaded and installed the most recent version of Moodle for Windows and tried again after enabling debugging.

I've attached the error message.
I'm afraid I don't understand what it means. thoughtful

Cheers,
Glenys

 
Average of ratings: -
Picture of Russ Williams
Re: error: Could not restore modules
 
I'm having a similar problem ... and have worked the suggestions offered in the forum posts above.

I think this is a serious bug in that I can no longer backup or restore a course. Everything was working fine last week.

Can someone tell me what happened between Friday and last night?

russ
 
Average of ratings: -
Picture of Howard Miller
Re: error: Could not restore modules
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
Did you *definitely* turn Debugging to "Full"? I would expect to see some additional information being generated in there.

EDIT:
Also... if you can put the backup file somewhere I can download it, I don't mind having a try myself.

EDIT EDIT:
MDL-18784 - doesn't help much though
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Hi Howard,

I had debugging on "ALL", will now change to "DEVELOPER" and run through a restore again. Be right back...

It would be fantastic if you try with the backup file I have, thank you! I'll find a place to put the backup file and let you know via email, OK?


Thanks!
Pauline
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
OK, here's another save of the errors shown. It looks like maybe it's not finding an image file. I'm going to try another restore with the experimental split restore enabled too. Will attach that to a separate post.
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
And here's the debugging from a restore done with experimental split enabled. There are 3 html files in a zip archive.

Thanks again!
Pauline
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Forgot to say which versions the backup and restore were from (for my latest attempt)...

The backup was made on a Moodle version 1.9.4 (20090128).

The restore was done on a local installation with the most recent update 1.9.4+ (20090401).

Thanks!
 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
I got the restore to work, but it might well be a hack that's not advisable, don't know.

The debug message said that the 'reference' column for 'mdl_resource' could not be null. So I changed that column's null property to yes in the database. Then the restore worked. Yeeha. surprise

Doing restore in version 1.9.4+ (weekly 20090401).
MySQL 5.0.19, PHP 5.1.6


Now the real question is, what will this change break elsewhere??

I did the database change on a local installation where it doesn't really matter, and wouldn't advise doing this on a real installation, whether test or production, until a moodle developer says otherwise.

Howard? stronk7?


Cheers,
Pauline
 
Average of ratings: -
Picture of Howard Miller
Re: error: Could not restore modules
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
Well.... this all depends on the problem....

* Did it fail because the field should not have been "not null"?
* Did it fail because the code should not have been writing a null to that field?


I have no idea........ let's just hope you backed the right horse as it where smile
 
Average of ratings: -
Picture of Howard Miller
Re: error: Could not restore modules
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
Ok.... I had a look at the backup file you sent me.

Fundamentally, the problem was with the backup part of the process not the restore. This has happened because there (almost certainly) where NULLs in the database field 'reference' in mdl_resource. I would want to check if that was a possibility.

I had a quick look at the db code and it doesn't look like anything has changed in those definitions for years (the oldest site I have is 1.6 and that is still 'not null'). So if it turns out, in the source Moodle, that you have NULLs in that field you have a kind of low-level data corruption. If your Moodle site has been upgraded a few times this is quite a common occurrence (due to inconsistencies in the db upgrade code).

Without doing some more digging that field's contents are dependent on what resource type it is. If a file link it will have the file reference otherwise it contains a number (always an empty string for me for 'html' resource types) but I don't remember what that means.

EDIT:
Just checking.... is the 1.9.3 install using MySQL?

 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Hi Howard,

Thanks so much for digging into that for me.

"So if it turns out, in the source Moodle, that you have NULLs in that field you have a kind of low-level data corruption. If your Moodle site has been upgraded a few times this is quite a common occurrence (due to inconsistencies in the db upgrade code)."

This could very well be the case, but I don't know. I'll try to get the support folks to take a look at this discussion and maybe give some input.

So that data corruption... do you mean that somehow the database where the backup is being made has numbers or empty strings and has converted them to NULLs?

What would you suggest to fix the problem? Is there something the support folks can do to clean out the NULLs and prevent them from occurring in future?



"EDIT:
Just checking.... is the 1.9.3 install using MySQL?""

Correction: The backup came from a 1.9.4 (20090128) install (I had noted that incorrectly above).

I don't know what kind of database it's using - again I'll have to ask the institution's support folks if they can come by and complete that info.

Thanks again Howard!
Pauline
 
Average of ratings: -
Picture of Thomas Korner
Re: error: Could not restore modules
Group Moodle Course Creator Certificate holders
Hi Howard and Pauline
I'm working for the institution support Paulines courses are located in.

We are using 1.9.4 ((20090128) with PostgreSQL 8.1.11 (operating system) and 8.1.9 on the test site (where we tried to import the course).

Howard, thank you for the hint. We have changed the "Not-NULL"-statement in the import-database and the import worked fine.

This action solved our problem but not the problem of the database on our live system. Is there a way to correct the corruption?

Regards
Thomas

 
Average of ratings: -
Picture of Pauline McNamara
Re: error: Could not restore modules
 
Hi all,

Just to make it absolutely clear... wink

The live system that Thomas refers to is the one that produced the corrupted backup. We'll need to create backups for a number of courses from that system.


Thanks much for your help,
Pauline
 
Average of ratings: -
Jeff Harwell
Re: error: Could not restore modules
 
We were having the same issue migrating courses from our production system (1.9.5+ 20090617) to a fresh install of Moodle (1.9.6+ 20091111). Both installs are using Postgresql 8.1 as their database. Our production system started years ago on Moodle 1.6 and has been upgraded several times. As Howard Miller suggested above (excellent post btw. thanks so much!) the upgrades had left the table mdl_resource on our production system with different column constraints than the mdl_resource table on the new install. Specifically in production the column mdl_resource.reference looks like this:

reference | character varying(255) |

But the same column (mdl_resource.reference) in the new install looked like this:

reference | character varying(255) | not null default ''::character varying

I did not want to remove the 'not null' constraint from the new install so in order to get backup/restore working from the production system I repaired the database on the production system by replacing all of the null values with the empty string '' and then adding the 'not null' and the default '' constraints to the production table. After I repaired the database I did a new backup from the production system (actually from a repaired clone of the production system) and was able to restore in the fresh install of Moodle 1.9.6+ without any issues. Below is the procedure that I used, please note that I did a clone of our production system and upgraded the clone from 1.9.5+ to 1.9.6+ just to be safe. This may or may not be necessary.

  1. Cloned our production system to a new server (basically did a restore from a full backup of production onto a new server)
  2. Upgraded the clone from 1.9.5+ to 1.9.6+ (just to be safe, might not be necessary)
  3. Used psql to connect to the database being used by the clone
  4. Replaced all the null values with an empty string
    1. update mdl_resource set reference = '' where reference is null;
  5. Verified that no null values remained (below query returned 0 rows)
    1. select count(*) from mdl_resource where reference is null;
  6. Added the default value of '' to the column
    1. alter table mdl_resource alter column reference set default '';
  7. Added the 'not null' constraint to the column
    1. alter table mdl_resource alter column reference set not null;
  8. Examined the table to make sure that the changes looked correct
    1. \d mdl_resource;
 
Average of ratings: -
Picture of gabriel gabriel
Re: error: Could not restore modules
 
I have the same problem, and this solution doesn´t work for me, can i send you the backup archive?
The size of the backup is 3.7 Mb
 
Average of ratings: -
Picture of Mohan V
Re: error: Could not restore modules
 

Restore problems

I thought I will share with you guys am not sure whether this will help you in any ways.

The live server with all three kinds of options (new course, adding it to existing course, deleting it first and new course) selected seems to work fine.

The restore procedure takes much longer than 1.8.2+ version

Server spec.
Moodle version - upgraded from 1.8.2+ since july 2008 to 1.9.2
Windows server 2003, Php 5.2.3 Apache 2.2.3 Mysql 5.0.45
Memory - 16 GB
Cpu intel xeon 5355 2.66 GHZ

Php.ini
memory_limit = 512MB
max_execution_time = 120

On the Testing server all three kinds of options (new course, adding it to existing course, deleting it first and new course)  seems to fail  ONLY if certain modules (e.g questionnaire) were  included in the backup. other wise it seems to work fine

  
However there was a backup of 5 mb without questionnaire module did not work on Testing Server but  it worked fine on live server. 

Error message from testing server: - An error has occurred and the restore could not be completed! 

Server spec.
1.9.2
Windows server 2003, Php 5.2.3 Apache 2.2.3 Mysql 5.0.45
Memory – 2 GB
Cpu intel ® xeon 2.39 GHZ
memory_limit = 128MB
max_execution_time = 120

I think it could be that because the live server has more processing power and 16 gb memory otherwise it is exactly same as testing server (source code)

 
Average of ratings: -
Picture of Yann Desbiolles
Re: error: Could not restore modules
 

Hello everyone !

I have the "Could not restore modules" problem too...
Like Pauline, I created a backup on a Moodle 1.9.11 online installation and I tried to restore the course on a Moodle 1.9.19 (Moodle4Mac).

The problem occurs everytime I try to restore a course with Nanogong data (The "could not restore" message appears after trying to restore the Nanogong exercises). I tried to restore the courses without these data and it works perfectly ! But sadly, even if I'm pretty sure the problem come from the Nanogong add-on, I can't do without it...

I enabled debugging (full and developper), but I have absolutely no error message, except the "Could not restore" one. So I'm totally blind here. :/

Could anyone help me on this ? 

Thank you for your help ! ;)

 
Average of ratings: -
Picture of Yann Desbiolles
Re: error: Could not restore modules
 

I'm sorry to "up" this post but i'm definitely in need for help on this one...
Does anyone have any clue on what should I do to work out this problem with Nanogong backup ?

Best regards,

Yann

 
Average of ratings: -