Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup and restore support #4

Open
nadavkav opened this issue Jun 27, 2017 · 22 comments
Open

Backup and restore support #4

nadavkav opened this issue Jun 27, 2017 · 22 comments
Assignees

Comments

@nadavkav
Copy link

Any ideas about this? as we are about to start implementing it.

@mchurchward
Copy link
Contributor

Nope. I haven't come up with any way to support this except through core changes.

@nadavkav
Copy link
Author

Should we open an MDL in the tracker for those core changes? are you happy with them?

@emdalton
Copy link

emdalton commented Aug 8, 2017

Good point, we really need backup/restore support. Maybe this can be part of the impetus for making this part of Core (or implementing hooks... ;) )

@mchurchward
Copy link
Contributor

mchurchward commented Aug 8, 2017

I would think it might be worth considering adding core backup/restore support for local plugins. Although, it might be difficult since local plugins exist outside of a course context.

@nadavkav
Copy link
Author

Until we have core support, maybe... we can have a dummy metadata module that we add to each course with only backup and restore implemented?

@nadavkav
Copy link
Author

Interesting: https://tracker.moodle.org/browse/MDL-55943

@nadavkav
Copy link
Author

Found a promissing example for implementation :-)
https://github.com/synergylearning/moodle-local_filterurlresbak/tree/master/backup/moodle2

@mchurchward
Copy link
Contributor

Since core supports it, we can add it. I would suggest the correct places to implement it would be in each context subplugin.

@nadavkav
Copy link
Author

Yep. like mod/assign subplugins did.

@mchurchward
Copy link
Contributor

@nadavkav are you going to implement any of the backup/restore code? Or are you looking for me to do that? Just setting my plans.

@nadavkav
Copy link
Author

We are (one of my team, or me). sorry for no being clear on this.

@kirildevlion
Copy link

@mchurchward Hi, i tried to implement backup/restore, with local plugins. It seems that moodle does not add backup nested elements to XML in local metadata plugin. Maybe you can advice how to implement it? Thanks!
My commit here:
devlionco@e091016

@nadavkav
Copy link
Author

nadavkav commented Nov 7, 2017

@kirildevlion , please give a more descriptive name to process_localkiril 😄

@seb-vial
Copy link

seb-vial commented Sep 21, 2018

Hey,

I've managed to implement backup/restore for the plugin. BUT

  • Course metadata is saved and restored
  • Module metadata is saved and restored

And that's it...
What I can't figure out is how to backup/restore groups metadata.

For other metadata types (users, categories, cohorts), I don't think that's possible and more to the point, I think that's not useful as they can be used in courses, but their metadata is not specific to each course.
Also I've tried to implement backup/restore in each subplugin as suggested, but what I did had no effect. From what I understood from the documentation and Moodle code, the main plugin has to create its own xml file, and then subplugins can hook into that file. IMHO metadata should not be in a different file but injected where it belongs.
So I simply created 2 files :

  • backup_local_metadata_plugin.class.php located in /moodle-site/local/metadata/backup/moodle2 to handle backup for course metadata and module metadata. Each metadata is added in the according xml file (course/course.xml for course metadata and activities/activity_xxx/module.xml) in the generated zip file. I just haven't been able to backup group metadata in groups.xml
  • restore_local_metadata_plugin.class.php located in /moodle-site/local/metadata/backup/moodle2 which does the inverse, it's called when you restore a course and restore course metadata and module metadata.

@nadavkav
Copy link
Author

Thank you @Birssan for sharing this code! I have downloaded it and it work great in our Moodle instance.
(When backing up a course and a module, of course. we are not using MD on other context levels)

@seb-vial
Copy link

It works fine for our Moodle as well, I guess it needs further testing though.

We only use metadata for modules as you do, but It would be nice if this feature is available for every metadata types.

@mchurchward
Copy link
Contributor

Finally getting around to looking at this. @Birssan where is the code you created?

@seb-vial
Copy link

seb-vial commented Dec 4, 2018

@mchurchward I haven't made a PR yet, I actually wanted to get your input on what I explained first. How come it's only possible to backup/restore course and module metadata but not the rest ?
I just pushed it to my fork if you want to check it out seb-vial@d4a2312
I now wonder how and where did @nadavkav get my code for this ?

@nadavkav
Copy link
Author

nadavkav commented Dec 4, 2018

@Birssan I got it from your repo, as far as I remember.
We use it. and it works fine.
We also have a fileupload field type, that gets a backup/restore for the file on the module context level.
It's on a private gitlab, in our campus, so I will push it into a public repo, so you can all enjoy it too. (hopefully, this weekend)

@seb-vial
Copy link

seb-vial commented Dec 5, 2018

That's what I thought too, but turns out I hadn't pushed it, so I only pushed it yesterday. Anyway, not really important, you have it and it works, that's enough :p

@mchurchward
Copy link
Contributor

Sorry I'm so late to the party here. This would still be a great addition.
Some questions:

  1. If you restore a metadata item that does not exist in the system when it is restored, what happens?

  2. How does the restore know that the data it is restoring is associated with the correct metadata item? Does it compare shortnames and fieldtypes? I wonder how custom user and course fields handle this...?

@susyzan
Copy link

susyzan commented Oct 7, 2021

Hi! Is anybody able to give an update about this feature please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants