The following works for versions 2.6, 2.7, and 2.8.
command line backup of a course to a designated directory.
Advantage: apache not involved. browser not involved. shows all courses (hidden or not)
To facilitate finding the parameters for the command line backup.php script one
needs either the course ID or the course shortname.
Thus: getcourses script
Place in moodlecode/admin/cli/
(paste the line below)
mysql -u [user] -p[password] -e "use [DB];select id,fullname,shortname from mdl_course;" > courses.txt;cat courses.txt
Change: [user], [password] and the [DB] for your moodle setup
Save the script: [ctrl][x]
chmod u+x getcourses
To execute: ./getcourses [ENTER]
Output looks like:
id fullname shortname
1 Moodle26 MDL26
3 Tinker TINKER
6 Creating Student e-Portfolios with Google Sites eportfolio
34 SA SA
37 iPads 101 iPads
39 M2 GBU! M2GBU
41 Advanced Moodle Administration (Linux) AMA
1689 Android Apps ANDROID
1690 2 Moodles Compared 2MDLCOMP
To use with php backup script.
* condition: /home/m26backups destination directory must exist ... create it first.
php backup.php --courseid=3 --destination=/home/m26backups/
If you have done everything correctly, the output will look like this:
== Performing backup... ==
It works and it's much faster than using browser:
[root@sos cli]# ls -l /home/m26backups/
-rw-rw-rw- 1 root root 676693868 Mar 19 12:27 backup-moodle2-course-1689-android-20150319-1126.mbz
-rw-rw-rw- 1 root root 1495593 Mar 19 12:29 backup-moodle2-course-1690-2mdlcomp-20150319-1129.mbz
-rw-rw-rw- 1 root root 6091492 Mar 19 12:24 backup-moodle2-course-1-mdl26-20150319-1124.mbz
-rw-rw-rw- 1 root root 15484102 Mar 19 12:28 backup-moodle2-course-37-ipads-20150319-1128.mbz
-rw-rw-rw- 1 root root 33779286 Mar 19 12:25 backup-moodle2-course-39-m2gbu-20150319-1125.mbz
-rw-rw-rw- 1 root root 67909147 Mar 19 12:27 backup-moodle2-course-3-tinker-20150319-1127.mbz
-rw-rw-rw- 1 root root 67909147 Mar 19 12:43 backup-moodle2-course-3-tinker-20150319-1143.mbz
-rw-rw-rw- 1 root root 25751960 Mar 19 12:28 backup-moodle2-course-41-ama-20150319-1128.mbz
-rw-rw-rw- 1 root root 9290356 Mar 19 12:28 backup-moodle2-course-6-eportfolio-20150319-1128.mbz
1. backup.php isn't in version 2.6, but one can place the backup.php file from 2.7/2.8 moodle files in moodlecode/admin/cli/ and it will work. And, since I no longer have any version below 2.6 don't know that it will work in earlier versions of Moodle, but it doesn't hurt to try it! (better yet, why not upgrade?)
2. am a bash shell script wanna be so it's crude, but gets the job done for now. However, someone with more experience could possibly turn the script into a looping script such that it executes one time, yet gets all the courses.
3. don't do "Wonders", but maybe someone with 'powershell' knowledge could do the same/similar.
'spirit of sharing', Ken