Complete Restore not working...

Complete Restore not working...

by Andrew Grant -
Number of replies: 7
Here are the basics. I am using to Mac OS 10.3.4 systems (not server). I have a working copy of Moodle on a tower. All is good. I now want to perform a full site backup and restore it onto my laptop. All is not good.

Here are the details. I used the Backup feature in Moodle. That worked. I then copied the zip files to the laptop which is running moodle. Restored and one of the courses showed up with a funny name. No worries... part of learning.

I noticed that the theme was no longer green but was now orange (the default theme). First indication that something didn't restore 100%.

No worries, I read a bit more and decided that a full backup required some Unix scripting on my part. So, I started into the Man pages for tar.

Now I made a simple backup script with tar to grab the DB, the entire site, and the Data folder.

I thought that would be all I would need. I then coped the tar balls over to my laptop and restored them.

This is where it gets weird. After restoring, everything is the same as before when the theme was back to default and the course name was wrong. The logs show all the activity from the tower though.

I didn't restart Apache or even stop SQL when I did the backup... Do I need to?

Why would this not work? Next, I got drastic and deleted all of the folders for the DB, Data, and the site. Then restored. Everything is there now. I logged back in... and everything is back to the way it was... wrong theme, wrong course name... I don't get it.

Here is the backup script:

cd /usr/local/mysql/data
tar cZf /moodle.DB.tar ./moodle
chown andrewgrant:admin /moodle.DB.tar
cd /Library/WebServer
tar cZf /MoodleData.tar ./MoodleData
chown andrewgrant:admin /MoodleData.tar
cd /Library/WebServer/Documents
tar cZf /moodle.site.tar ./moodle
chown andrewgrant:admin /moodle.site.tar

Here is the restore script:

cd /usr/local/mysql/data
tar xZf /moodle.DB.tar
cd /Library/WebServer
tar xZf /MoodleData.tar
cd /Library/WebServer/Documents
tar xZf /moodle.site.tar

Does anyone have a clue or answer for this one? angry
Average of ratings: -
In reply to Andrew Grant

Re: Complete Restore not working...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Andrew,

I think that you are a bit "confused" with backups:

- COURSE backups are used to backup individual courses (to save or to move them to another server). They don't include any site-level information (theme, site configuration, active modules...).

- SITE backups are used to backup and entire site (to save or to move it to another server). They are a "snapshot" of the entire Moodle site and, when restored, the new site will be exactly as the old one (same courses, configuration...).

So, if you want to move your entire Moodle site from your tower to your laptop, you have to use the 2nd type of backup. You can see this link about how to do SITE backups.

Ciao smile

In your example above, I think that making a tar file of the MySQL database can produce problems. The proper manner to do it is to use the "mysqldump" command instead.
Average of ratings: Useful (1)
In reply to Eloy Lafuente (stronk7)

Re: Complete Restore not working...

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Actually, moving all the database files directly (via tar or not) is OK as long as you shutdown the MySQL server cleanly before doing it.

On Linux you can do this as root:

   mysqladmin shutdown

then move or copy your files and then start the database again using

   /etc/init.d/mysql start
Average of ratings: Useful (1)
In reply to Martin Dougiamas

Re: Complete Restore not working...

by Ger Tielemans -

I made (on purpose) a complete backup and restore from 1.2.x to 1.3.1 and from a Linux Debian to a RedHat Walhalla with the single course backup and restore, to check the internal consistency of all these old courses. (Some started on version 1.0) I have only one cripled one, yes that is my ownsmile.

All went well with three exceptions:

  • Courses with incorrect signs in the short name (like &) did not want to restore, until I changed  that sign
  • Some long names showed the same & incorrect as htmlcode on the screen
  • The relativ paths in the HTML-editor. (see elsewhere)

So I would say that it is very stable smile


I only lost one course (of course from my most critical user, who says that BB has better studentroomssmile). The reason was that all these courses got wild names and I killed (wrongly) a double name.

So I would prefer to have shortnames, build from a set of drop-downboxes like:

AABBCCDDEEFF

AA= dropdownbox for learning topic area  (Institute fills the choices)

BB= dropdownbox for learning year  (Institute fills the choices)

CC= dropdownbox for learning stream /program (Institute fills the choices)

DD= dropdownbox for location /institute  (Institute fills the choices)

EE= dropdownbox for part of the year  (Institute fills the choices: semester 1 2, trimester 1 2 3, Quartiel 1,2 3,4 / Unbound)

FF= dropdownbox for version number (Author maintains this choice?)


On the course homepage I show already HOME instead of shortname, but in references in the forum the shortname will still be used, therefor it must stay a readable code for humans smile

In reply to Eloy Lafuente (stronk7)

Re: Complete Restore not working...

by Andrew Grant -
Thank you. The link you provided worked great! Try as I may, I was not able to find the link to explain how to import the Dump file from SQL.

When I tried to follow the steps 2 issues came up (I am getting closer!).

Now that I deleted the DB on my laptop and have created a new DB with the same name (as per the documentation), when I attempt to bring in the dumped DB I get this error consistantly:

ERROR 1062 at line 71: Duplicate entry '1' for key 1

This seems to happen everytime I 'rm -r moodle' to get rid of my moodle DB under /usr/local/mysql/data.

When I login to the site, it takes my login and password then takes me to the site's home page and shows that I am not logged in. If I click the login link... the same thing happens.

What did I do wrong?

Also, is there a way to script the creation of a blank DB? I tried to guess at the syntax... but I keep getting an error saying that moodle is not a valid command.

My line looks something like this in my script:

/usr/local/mysql/bin/mysql -h localhost -u root --password=PasswordHere CREATE DATABASE moodle;

I tried to use the same basic logic to script the rest of the commands as well.

Is there a way to do this correctly? I am trying to figure this out so I can setup a restore process that a "non-technical" and "non-unix" person can run to automate the process.

Thank you,

Andrew
In reply to Eloy Lafuente (stronk7)

Re: Complete Restore not working...

by Andrew Grant -
Now that I deleted the DB on my laptop and have created a new DB with the same name (as per the documentation), when I attempt to bring in the dumped DB I get this error consistantly:

ERROR 1062 at line 71: Duplicate entry '1' for key 1

This seems to happen everytime I 'rm -r moodle' to get rid of my moodle DB under /usr/local/mysql/data.

When I login to the site, it takes my login and password then takes me to the site's home page and shows that I am not logged in. If I click the login link... the same thing happens.

What did I do wrong?
In reply to Andrew Grant

Re: Complete Restore not working...

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Uhm, now I'm a bit confused!! wink

Do you mean that you execute the "rm -r moodle" command to delete the "moodle" database? I'm not sure it it's correct, specially having the DB running.

I think that you should do is to "DROP" the database correctly (from any mysql interface, like phpMyAdmin or using this:

mysqladmin drop moodle -u root -p

Then your database will be correctly erased and you will be able to create it again (as documented in the installation guide) and load your dump file in it.

Hope it helps, ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Complete Restore not working...

by Andrew Grant -
Thank you so very much. I am not at all familiar with MySQL. That little piece of information just resolved all of my issues.

Thank you again. It is so wonderful that you would take the time to show me the very basics. I have just installed myPHPAdmin and feel that I am getting a better grasp on how to work with MySQL.

This also answered my question about the login screen jumping back to the login prompt each time I logged in. I checked all the perms and there wasn't Read permission on the moodleData folder. That resolved that issue as well.

Thank you again.

Andrew