Backup and restore

Hide courses excluded from automatic backup. Why?

 
Picture of Juan Marín
Hide courses excluded from automatic backup. Why?
 
The automatic backup procedure skips all the courses I have hidden to students. I didn't found any option to check or disable in backup configuration.

How can I to change this behaviour?

I want to have a backup of the changes that teachers do, even before to publish the course to students.

(I could set the backup status from 3 to 1, manually, in the DB. But I think it would be another way to do it)

moodle 1.7.2
 
Average of ratings: -
Picture of Aye-mon Myo
Re: Hide courses excluded from automatic backup. Why?
 

Hi, I'm having the same problem. Moodle cron does not seem to work for hidden courses. Does anyone has any idea? Thanks.

 
Average of ratings: -
Picture of Zoe Bogner
Re: Hide courses excluded from automatic backup. Why?
 
I think the function that controls the skipping of hidden and unmodified backups (in 1.8.3 at least) is in backup/lib.php around line 103, which says:


// Skip backup of unavailable courses that have remained unmodified in a month
 $skipped = false;
 if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
 mtrace(" SKIPPING - hidden+unmodified");
 set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
 $skipped = true;
 }

Change this to:


// Skip backup of courses that have remained unmodified in a month
 $skipped = false;
 if (($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
 mtrace(" SKIPPING - unmodified - last modified ");
 set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
 $skipped = true;
 }

However, there seems to be some other force at work, as for a course to be seen as 'modified', I had to briefly make it visible (and then hide it again). I don't know if further changes will be picked up by the cron... I'll look into it some more.
 
Average of ratings: Useful (1)
Health & Safety Training Ninja
Re: Hide courses excluded from automatic backup. Why?
 
Hi,

Rather than changing the code so much you could simply alter the time period.

change this line below :

 if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
To :

 if (!$course->visible && ($now - $course->timemodified) > 12000*31*24*60*60) { //Hidden + unmodified last month

Now 12,000 months must pass before it will skip backups, does anyone see themselves using their current version of Moodle for the next 1000 years??? tongueout

Steve
 
Average of ratings: Useful (1)
Sketch...
Re: Hide courses excluded from automatic backup. Why?
 

In Moodle 1.9 this code is now in the \backup\backup_scheduled.php file near line 105.

I found it a useful solution for a once-off need that I had to schedule a backup of ALL my courses.

 
Average of ratings: -
Picture of Konrad Lorinczi
Re: Hide courses excluded from automatic backup. Why?
 

Well, if I want to backup all courses completely, then I need to completely ignore (comment out) the mentioned condition like this (line 105-109):

// if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) {  //Hidden + unmodified last month
// mtrace("            SKIPPING - hidden+unmodified");
// set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
// $skipped = true;
// }

 

Also need to mention, if too much courses are backuped, then the PHP script will time out, so the backup procedure will stop at specific point (usually after 30 seconds).

This is the reason, why I do put set_time_limit(30); command into the loop, to extend the backup script execution time.

Change the following lines (around line 86-87):

foreach ($courses as $course) {
if ($status) {

to

foreach ($courses as $course) {
set_time_limit(30);
if ($status) {
 
Average of ratings: -