Restore courses from remote Moodles

Blocks ::: block_my_external_backup_restore_courses
Maintained by Céline Perves
block my_external_backup_courses : Restore courses from remote moodle platforms my_external_backup_restore_courses is a Moodle block that enable a user to restore courses from external moodles this block must be installed in each moodle course clients and course servers involved
Latest release:
129 sites
138 downloads
17 fans
Current versions available: 5

block my_external_backup_courses : Restore courses from remote moodle platforms

my_external_backup_restore_courses is a Moodle block that enable a user to restore courses from external moodles this block must be installed in each moodle course clients and course servers involved

Features

  • enable a user to program course restoration, where courses comes from external moodles
  • depending of his role capabilities he can restore courses with user datas
  • possibility to find the original category based on unique category identifier threw plugin settings on database relation (user must hace moodle/course:create in the category context)
  • restore cours in a default category (user must hace moodle/course:create in that context)
  • a scheduled task will launch remote backups and restorations of these courses
  • Log and messaging include to notify of success or failure
  • possibilily to restrict to only one restoration by course
  • admin tool to see list of backup/restore tasks
  • admin tool to restore a course for a user

Security warning

  • This plugin use a capability block/my_external_backup_restore_courses:can_retrieve_courses that enable webservice account to donload backup files of other users
  • To improve security it is strongly recommended to generate token with IPrestriction on server side IPs

mnet warning usage

this plugin may not work in MNet environments fully because the username in that conditions username is not unique

Download

from moodle plugin repository

Installation

Block installation

Install block on blocks directory in course clients moodles and in each course servers moodle you need to connect to

webservice settings

On moodles that serves courses

install by cli or manually

install with cli command

  • execute cli, that will install webservice, rôle and user
  • you will only need to generate token (see after)
generate token
  • Under Site administration -> Plugins -> Web Services -> Manage Tokens
    • create a new token, restricted on your php server(s) for the custom external sservice previously created
      • by cli user is named block_my_external_backup_restore_courses_user
    • This token will be one to be entered in the block parameters of block_my_external_backup_restore_courses on client moodles.
    • for more security restrict webservice usage on IP

Block setting

Essential settings

On moodles that serve courses (moodle servers) and client moodles

  • Under Plugins -> Blocks -> Restore courses from remote Moodles For each moodles you need to fill the following setting parameters 
  • in my_external_backup_course | search_roles enter roles to include in course search simple quote delimited text shortname separated by commas
  • in my_external_backup_course | restorecourseinoriginalcategory activate the mode that enable to try to search the original category of a remote course 
  • in my_external_backup_course | categorytable the database table name where to find unique identifier information in order to search/find category, common for both client and server moodles
  •  in my_external_backup_course | categorytable_foreignkey the database foreign key for categorytable
  • in my_external_backup_course | categorytable_categoryfield the database field in categorytable unique for a category and common for both client and server moodles 

Cli install version for moodle version 4.0 and above 

  •  the following commands are the ones for traditional moodles

On course clients moodles
  • in my_external_backup_course | defaultcategory the categoryid where the course will be restored by default, users that restore must have capability to moodle/course:create
  • in my_external_backup_course | externalmoodles formatted list of course servers moodles formatted as moodle_url1,token_compte_webservice_moodle_externe1;moodle_url2,token_compte_webservice_moodle_externe2;… 

Cli install version

  • for moodle version 4.0 and above
Cron setting

On Site administration -> Server -> Scheduled tasks * Edit “Restore course from remote Moodles” task to determine when restore process is launched

capability

  • in order to use this block in dashboard a capability block/my_external_backup_restore_courses:view is provided and by default allowed for coursecreator and manager profile
  • This enable to control block visibility in dashboard
  • course restore and backup is virtually proceed with an admin account so the resquester user does not need special capabilities anymore
    • except course:create in category if checkrequestercapascoursecreate setting is checked

Optional interesting settings

Messaging

  • Site administration / ► Plugins / ► Message outputs / ► Default message outputs
  • 2 message outputs :
    • Notify that an external course as failed to restore
    • Notify that an external course is successfully restored
  • by default allowed and permitted for mails

role

  • In Site administration -> Plugins -> Blocks -> Restore courses from remote Moodles
  • block_my_external_backup_restore_courses | search_roles : enable to change/add moodle role used to search remote courses to restore

Restriction

  • In Site administration -> Plugins -> Blocks -> Restore courses from remote Moodles
  • block_my_external_backup_restore_courses | onlyoneremoteinstance : Only one restoration is authorized by course
  • block_my_external_backup_restore_courses | enrollrole :
    • define the role that the requester will have in the restored course
    • define the role in which the user will be re enrolled to course through the given button in the backup external course button

Contributions

Contributions of any form are welcome. Github pull requests are preferred. Fill any bugs, improvements, or feature requiests in our [issue tracker][issues].

License

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4
Screenshot #5
Screenshot #6
Screenshot #7
Screenshot #8
Screenshot #9

Contributors

Céline Perves (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Céline Perves
    Fri, 16 Apr 2021, 5:17 PM
    I just pushed my work on 3.9 version with a new cli tool to preprare webservices (user,role, service definition)
    you'll find it on https://github.com/cperves/moodle-block-my_external_backup_restore_courses 39_devel branch
    I'll push it on moodle.org when validated
    do not hesitate to report any encountered issues on github
  • Céline Perves
    Mon, 20 Feb 2023, 11:39 PM
    new 4.0 and 4.1 version strongly improved
  • Fábio Gongora Freire
    Wed, 24 May 2023, 7:32 PM
    Hello. I'm trying to restore courses from a moodle 3.9 to moodle 4.1.3 but I got this problem:
    Execute scheduled task: Restore course from remote Moodles task (block_my_external_backup_restore_courses\task\backup_restore_task)
    ... started 13:09:53. Current memory use 14.0 MB.
    ... used 8 dbqueries
    ... used 0.48208284378052 seconds
    Scheduled task failed: Restore course from remote Moodles task (block_my_external_backup_restore_courses\task\backup_restore_task),error/invalidparameter
    Backtrace:
    * line 581 of /blocks/my_external_backup_restore_courses/locallib.php: call to block_my_external_backup_restore_courses_tools::rest_call_external_courses_client()
    * line 508 of /blocks/my_external_backup_restore_courses/locallib.php: call to block_my_external_backup_restore_courses_task->download_external_backup_courses()
    * line 41 of /blocks/my_external_backup_restore_courses/classes/task/backup_restore_task.php: call to block_my_external_backup_restore_courses_task_helper::run_automated_backup_restore()
    * line 263 of /lib/cronlib.php: call to block_my_external_backup_restore_courses\task\backup_restore_task->execute()
    * line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()
    From moodle 4.1 to 3.9 it works but not from 3.9 to 4.1. Can someone give me some help? Thank you
  • Céline Perves
    Thu, 25 May 2023, 1:49 PM
    Hello,
    with this plugin you can't transfert courses from different Moodle major version.
    This is due to the fact that the plugin is based on Moodle class and functions that changes between version.
    The solution is to migrate your 3.9 platform to 4.1.3 version
    Hope this will help you
    Regards
    Céline
  • nandi widiyanto
    Sat, 27 May 2023, 2:13 AM
    Hi, Sorry i'm Newbie and i want to use this plugin but i stuck at installing the plugin and i dont know how to use it properly. Can you show the easier way or step by step how to do it.

    Much appreciated
  • Céline Perves
    Tue, 30 May 2023, 2:45 PM
    Hello, in order to help you can you opn an issue on the github page project. Specify ware you are blocked in it
    Regards
    Céline
  • nandi widiyanto
    Tue, 30 May 2023, 8:03 PM
    Already Post an issue in github. Thanks and waiting for your reply in github
  • Daniel De La Luz Tellez
    Wed, 25 Oct 2023, 2:18 AM
    No external Moodle connected, this option appears and I already followed the steps . in moodle 3.9
  • Céline Perves
    Wed, 25 Oct 2023, 2:24 PM
    I'll try to help you within your github issue
  • Guillaume Podevin
    Wed, 31 Jan 2024, 10:37 PM
    Hello, I have successfully tested the migration of a few courses with the editingteacher role but is it possible for a moodle admin or a member of another system role to migrate all the courses of a Moodle without necessarily being registered in them? What should the parameters be in this case?
  • Céline Perves
    Thu, 1 Feb 2024, 3:27 PM
    Hello, this plugin is based on the fact that you ask for restoration of the courses your are enrolled in with a particular role.
    This role is set in the plugin settings
    But as a Moodle admin you can restore courses for other people based on the courseid thanks to the admin page :
    Site Administration -> Blocks -> Restore courses from remote Moodles -> Restore course for user
    One course can be restored from its id

  • Sergio Renato Aldana Alvarez
    Tue, 6 Feb 2024, 6:49 AM
    I have some courses stuck in progress status, what can I do?
  • Céline Perves
    Tue, 6 Feb 2024, 3:52 PM
    May be a trouble while backup or restore a course
    You can look at the logs
    Passing by administrator tool you can change the problematic backup/restore course status to new for retrying to backup/restore it
  • Sergio Renato Aldana Alvarez
    Wed, 7 Feb 2024, 1:09 AM
    Here is the log:

    xecute scheduled task: Restore course from remote Moodles task (block_my_external_backup_restore_courses\task\backup_restore_task)
    ... started 12:00:27. Current memory use 22.8 MB.
    ... used 7 dbqueries
    ... used 420.79239416122 seconds
    Scheduled task failed: Restore course from remote Moodles task (block_my_external_backup_restore_courses\task\backup_restore_task),Error al leer de la base de datos
    Debug info:
    MySQL server has gone away
    SELECT * FROM mdlsb_course_categories WHERE id = ?
    [array (
    0 => '1',
    )]
    Backtrace:
    * line 291 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
    * line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
    * line 1671 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
    * line 1643 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
    * line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
    * line 1872 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
    * line 650 of /blocks/my_external_backup_restore_courses/locallib.php: call to restore_dbops::create_new_course()
    * line 513 of /blocks/my_external_backup_restore_courses/locallib.php: call to block_my_external_backup_restore_courses_task->restore_course_from_backup_file()
    * line 41 of /blocks/my_external_backup_restore_courses/classes/task/backup_restore_task.php: call to block_my_external_backup_restore_courses_task_helper::run_automated_backup_restore()
    * line 253 of /lib/cronlib.php: call to block_my_external_backup_restore_courses\task\backup_restore_task->execute()
    * line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
    * line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
    * line 81 of /admin/cron.php: call to cron_run()

    !!! Error al leer de la base de datos !!!

    Debug info: MySQL server has gone away
    SELECT RELEASE_LOCK(?) AS unlocked
    [array (
    0 => 'de655ed6b632008963cb8f4d1559dc47a14f389a',
    )]
    Error code: dmlreadexception
    Stack trace: * line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    * line 291 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
    * line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
    * line 1671 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
    * line 161 of /lib/classes/lock/mysql_lock_factory.php: call to moodle_database->get_record_sql()
    * line 107 of /lib/classes/lock/lock.php: call to core\lock\mysql_lock_factory->release_lock()
    * line 130 of /lib/cronlib.php: call to core\lock\lock->release()
    * line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
    * line 81 of /admin/cron.php: call to cron_run()
  • Céline Perves
    Fri, 9 Feb 2024, 9:32 PM
    do you really have a course category with id=1?
1 2 3 4
Please login to post comments