Moodle

An error occured deleting old backup data

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9
  • Fix Version/s: None
  • Component/s: Backup
  • Labels:
    None
  • Environment:
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_15_STABLE, MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

Description

Postings by bscheele at bottom of:

http://moodle.org/mod/forum/discuss.php?d=20269

Any help would be great!

Cheers,

Bob

  1. lib.php
    19/Sep/08 12:26 AM
    34 kB
    John T. Macklin
  1. backup-delete1.jpg
    55 kB
    19/Sep/08 12:30 AM

Activity

Hide
Peter Sereinigg added a comment -

the same with .1.6+
....?

Peter

Show
Peter Sereinigg added a comment - the same with .1.6+ ....? Peter
Hide
Samuli Karevaara added a comment -

We had this happen with 1.8.2+ (on one Moodle out of 8). DB + backup temp permissions were fine, but emptying the moodledata/temp/backup/ folder made the error go away. The cause of the problem remains, however (didn't have time to investigate, sticking with the workaround).

Show
Samuli Karevaara added a comment - We had this happen with 1.8.2+ (on one Moodle out of 8). DB + backup temp permissions were fine, but emptying the moodledata/temp/backup/ folder made the error go away. The cause of the problem remains, however (didn't have time to investigate, sticking with the workaround).
Hide
Wen Hao Chuang added a comment -

Is this issue also storage-engine related? We just switched some of the tables to Innodb and started to notice this problem, but when we have all tables on MyISAM we never got this type of errors. Thanks!

Show
Wen Hao Chuang added a comment - Is this issue also storage-engine related? We just switched some of the tables to Innodb and started to notice this problem, but when we have all tables on MyISAM we never got this type of errors. Thanks!
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Wen,

as commented in the original discussion:

http://moodle.org/mod/forum/discuss.php?d=20269

that step of backup (and restore too), simply performs 2 deletes in two tables (I guess MyISAM InnoDB can not cause any difference, it's only one delete). Anyway, to be 100% sure... if it's a database problem... then raising debug to developer level... you should see some sort of SQL error (on screen or in web server logs).

And the other action performed by that step is to delete, under temp/backup, all the old directories present there. And this use to be the problematic part, sometimes due to some perms problems and sometimes due to files using characters not allowed by the OS/PHP natively. That's the cause I recommend to, simply, delete the whole temp/backup manually.

Perhaps we could improve things a bit by enabling some sort of complete debug in the recursive deletion of temp/backup directories, to be able to know what file and why exactly is failing on each case, to be able to improve deletion code. But I haven't been able to reproduce that situation here (only by forcing perms or renaming things manually).

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Wen, as commented in the original discussion: http://moodle.org/mod/forum/discuss.php?d=20269 that step of backup (and restore too), simply performs 2 deletes in two tables (I guess MyISAM InnoDB can not cause any difference, it's only one delete). Anyway, to be 100% sure... if it's a database problem... then raising debug to developer level... you should see some sort of SQL error (on screen or in web server logs). And the other action performed by that step is to delete, under temp/backup, all the old directories present there. And this use to be the problematic part, sometimes due to some perms problems and sometimes due to files using characters not allowed by the OS/PHP natively. That's the cause I recommend to, simply, delete the whole temp/backup manually. Perhaps we could improve things a bit by enabling some sort of complete debug in the recursive deletion of temp/backup directories, to be able to know what file and why exactly is failing on each case, to be able to improve deletion code. But I haven't been able to reproduce that situation here (only by forcing perms or renaming things manually). Ciao
Hide
Dan Marsden added a comment -

Hi Eloy,

any reason why backup/lib.php has it's own "delete_dir_contents" function, when we could use the fulldelete() function from filelib.php - I can't see anywhere that the "excludedir" is used in backup functions.....

?

Dan

Show
Dan Marsden added a comment - Hi Eloy, any reason why backup/lib.php has it's own "delete_dir_contents" function, when we could use the fulldelete() function from filelib.php - I can't see anywhere that the "excludedir" is used in backup functions..... ? Dan
Hide
John T. Macklin added a comment -

See attached Screen Shot of the actual Error message...

Recently I was experiencing the same issues on one of our servers. Attached is a patched file which I used to avoid the issue on a '1.9.1 (Build: 20080515) Site.
/*

  • Filename: moodle/backup/lib.php
  • Revision: Patch for MDL-10017
  • Date: 9/18/2008 11:20:34 AM
  • Auth: John T. Macklin Remote Learner
    */

function backup_delete_old_data() {

global $CFG;

//Change this if you want !!
$hours = 4;
//End change this
$seconds = $hours * 60 * 60;
$delete_from = time()-$seconds;

$sql = "SELECT id FROM {$CFG->prefix}backup_ids WHERE backup_code < '$delete_from'";

if(record_exists_sql($sql)) // Do we need to clean up backup ?
{
//Now delete from tables
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
WHERE backup_code < '$delete_from'",false);
if ($status) {
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_files
WHERE backup_code < '$delete_from'",false);
}

//Now, delete old directory (if exists)
if ($status) { $status = backup_delete_old_dirs($delete_from); }
}else{ $status=true; // Nothing to do here! }

return($status);
}

Show
John T. Macklin added a comment - See attached Screen Shot of the actual Error message... Recently I was experiencing the same issues on one of our servers. Attached is a patched file which I used to avoid the issue on a '1.9.1 (Build: 20080515) Site. /*
  • Filename: moodle/backup/lib.php
  • Revision: Patch for MDL-10017
  • Date: 9/18/2008 11:20:34 AM
  • Auth: John T. Macklin Remote Learner */
function backup_delete_old_data() { global $CFG; //Change this if you want !! $hours = 4; //End change this $seconds = $hours * 60 * 60; $delete_from = time()-$seconds; $sql = "SELECT id FROM {$CFG->prefix}backup_ids WHERE backup_code < '$delete_from'"; if(record_exists_sql($sql)) // Do we need to clean up backup ? { //Now delete from tables $status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code < '$delete_from'",false); if ($status) { $status = execute_sql("DELETE FROM {$CFG->prefix}backup_files WHERE backup_code < '$delete_from'",false); } //Now, delete old directory (if exists) if ($status) { $status = backup_delete_old_dirs($delete_from); } }else{ $status=true; // Nothing to do here! } return($status); }
Hide
John T. Macklin added a comment -

moodle/backup/lib.php for 1.9.1 (Build: 20080515)

Show
John T. Macklin added a comment - moodle/backup/lib.php for 1.9.1 (Build: 20080515)
Hide
Eloy Lafuente (stronk7) added a comment -

Hi Dan,

I guess we have there such delete_dir_contents() function because, when backup was written, the fulldelete() function didn't exist.

Also... they are different, because fulldelete will delete the root directory itself, while delete_dir_contents() leaves it undeleted. Also... the excluded param seems to be used when restoring to existing courses... uhmm.

Show
Eloy Lafuente (stronk7) added a comment - Hi Dan, I guess we have there such delete_dir_contents() function because, when backup was written, the fulldelete() function didn't exist. Also... they are different, because fulldelete will delete the root directory itself, while delete_dir_contents() leaves it undeleted. Also... the excluded param seems to be used when restoring to existing courses... uhmm.
Hide
Eloy Lafuente (stronk7) added a comment -

Hi John,

while your patch looks ok, I cannot see why it does any difference. It improves things a bit (because deletion in only performed if there are records) but, after all, the same deletion code (two deletes and the backup_delete_old_dirs() ) is executed.

When were you getting errors then? I really don't see it.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi John, while your patch looks ok, I cannot see why it does any difference. It improves things a bit (because deletion in only performed if there are records) but, after all, the same deletion code (two deletes and the backup_delete_old_dirs() ) is executed. When were you getting errors then? I really don't see it. Ciao
Hide
Timothy Takemoto added a comment -

I am getting this on an old 1.63

I have had problems with file deletion for a long time. Backups are created but the previous backups are not deleted. I thought it was due to some server timeout problem and deleted old backup files by hand.

But now I can't backup or restore at all.

The one thing I did recently that I do not usually do (and may have started this error) was to restore to an existing course.

Show
Timothy Takemoto added a comment - I am getting this on an old 1.63 I have had problems with file deletion for a long time. Backups are created but the previous backups are not deleted. I thought it was due to some server timeout problem and deleted old backup files by hand. But now I can't backup or restore at all. The one thing I did recently that I do not usually do (and may have started this error) was to restore to an existing course.
Hide
Timothy Takemoto added a comment -

I used the patch above and it seems to be working...it got past the stage that had the error before,

but just at that minute my sysadmin got around to deleting the files in temp/backup so I got a different error message as expected.

But the patch above seemed towork in 1.6.3 too. I wonder what it does.

For the time being I will go back to my old lib.php and see if just deleting the files works.

And I will see if using the patch works on my old problem of non-deleting zip files. I doubt it does.

Show
Timothy Takemoto added a comment - I used the patch above and it seems to be working...it got past the stage that had the error before, but just at that minute my sysadmin got around to deleting the files in temp/backup so I got a different error message as expected. But the patch above seemed towork in 1.6.3 too. I wonder what it does. For the time being I will go back to my old lib.php and see if just deleting the files works. And I will see if using the patch works on my old problem of non-deleting zip files. I doubt it does.
Hide
mert gokkaya added a comment -

we are using Mssql enterprise with IIS and sql server logs giving this error

Autogrow of file 'moodle_log' in database 'moodle' was cancelled by user or timed out after 0 milliseconds. Use ALTER DATABASE to set a smaller FILEGROWTH value for this file or to explicitly set a new file size.
cleaning the folders did not help me much. I set autogrow to 50% or designated file size still no hope

Show
mert gokkaya added a comment - we are using Mssql enterprise with IIS and sql server logs giving this error Autogrow of file 'moodle_log' in database 'moodle' was cancelled by user or timed out after 0 milliseconds. Use ALTER DATABASE to set a smaller FILEGROWTH value for this file or to explicitly set a new file size. cleaning the folders did not help me much. I set autogrow to 50% or designated file size still no hope
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Dates

  • Created:
    Updated:
    Resolved: