Backup and Restore database content

Backup and Restore database content

by Paul Raper -
Number of replies: 12

I have a database that has a fair amount of data in it, but I would like to copy it over to another platform.

When I backup the database, for some reason it doesn't seem to include the content in the backup, and when I restore the database to the new location, the structure is there, but no data.

Any thoughts?

Average of ratings: -
In reply to Paul Raper

Re: Backup and Restore database content

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
What command are you using to backup your database, Paul?

And what method are you using to restore it?
In reply to Rick Jerz

Re: Backup and Restore database content

by Paul Raper -
Ok, so what I think may have got confused here is that I am referring to the Activity Database, not the main Moodle database.

I have a course that has a database activity which has a lot of content. I copied the course from a template course I have, and then found that for some reason, the database activity content seemed to have gone, or not copied with the course. I was wondering whether there was a way to somehow transfer the content over, i.e. back up the database activity and then restore it into the new course. I worked out a way to do this with the Glossary activity, but I am struggling a bit here with this one. Any ideas?
In reply to Paul Raper

Re: Backup and Restore database content

by Ken Task -
Picture of Particularly helpful Moodlers

" ... copied the course from a template course ..."

This 'course template' ...  is it hidden course? With users? Without users?

One should be able to run a backup, selecting only the DB activity to backup and restore that backup to an existing course (would come into course using sections as the last section in the existing course to which one is restoring).

Theme?   Version of Moodle?

'SoS', Ken

In reply to Ken Task

Re: Backup and Restore database content

by Paul Raper -
The course template has no users, but isn't hidden. There is a login key to keep users out.

I tried running the backup, but strangely got a database with no content: but there is content, I can browse it in the original course.
In reply to Paul Raper

Re: Backup and Restore database content

by C Behan -
Hi Paul,
You need to use the export feature: https://docs.moodle.org/310/en/Using_Database#Exporting_entries
Average of ratings: Useful (1)
In reply to C Behan

Re: Backup and Restore database content

by Joost Elshoff -
Picture of Particularly helpful Moodlers Picture of Testers
As C Behan already mentions, the following content of the following activities is only included if the student data is included in the backup file: Glossary, Wiki (I think), Database. This has to do with the fact that every entry a participant makes in these activities, is considered user-related data, and not course-related.

For Glossary, you'd have to export with XML, for Database, you'd have to use any of the export formats avaiable.
Average of ratings: Useful (2)
In reply to Joost Elshoff

Re: Backup and Restore database content

by Paul Raper -
Joost, that makes perfect sense now that you put it that way. @C Behan, I did try the Export route, but that didn't work either. The database comprises a whole bunch of files, PDF's etc which students are to use as a resource in the course. SInce these have been added by me, I guess the best way is to backup the course with the Users, me being the only one. I will then be restored to the new course, which I am enrolled into anyway. I'll give it a go and post my results.
Average of ratings: Useful (1)
In reply to Paul Raper

Re: Backup and Restore database content

by Matthias Giger -
Picture of Particularly helpful Moodlers
Backup the database with the users and use the anonymize option. Than import the backup into the course of your choice. When importing you also have to include users and the option which best works for me is "manual inscription".
Average of ratings: Useful (2)
In reply to Joost Elshoff

Re: Backup and Restore database content

by Paul Raper -
Ok, That worked. As soon as I made a backup that included the users, anonymized or not, I could import the database with all the data in it. Brilliant! It makes perfect sense when you think about it, but it is interesting that the glossary functions in a different way.
Average of ratings: Useful (1)