All Backups Fail - An error occurred while copying the zip file to the course directory

All Backups Fail - An error occurred while copying the zip file to the course directory

by Ceri Richards -
Number of replies: 8
Hi All,

I'm having major issues with course backups since I changed to using an external zip program for performance gains (OS - Server 2003, MySQL, IIS). Below is an example -

Name: backupDJ20080612.zip
  • Creating temporary structures
  • Deleting old data
  • Creating XML file
    • Writing header
    • Writing general info
    • Writing course data
      • Course info
      • Metacourse
      • Blocks
      • Sections
    • Writing users info
    • Writing scales info
    • Writing groupings info
    • Writing groups info
    • Writing events info
    • Writing gradebook info
    • Writing modules info
      • Forums
      • Resources
    • Course format data
  • Copying user files
  • Copying course files
  • Zipping backup
  • Copying zip file
An error occurred while copying the zip file to the course directory

I've checked my data directories permissions and the web-server has write access - I've even given everyone full control on my dev box which still doesnt work. Here are my system paths -

Path to zip zip C:\Program Files\GnuWin32\bin\zip.exe
Indicate the location of your zip program (Unix only, optional). If specified, this will be used to create zip archives on the server. If you leave this blank, then Moodle will use internal routines.
Path to unzip unzip C:\Program Files\GnuWin32\bin\unzip.exe
Indicate the location of your unzip program (Unix only, optional). If specified, this will be used to unpack zip archives on the server. If you leave this blank, then Moodle will use internal routines.

As soon as I revert back to the internal zip program my backups work fine. Any ideas? I've also searched the forums but havent been able to find anything.

Thanks in advance,
Ceri

Average of ratings: -
In reply to Ceri Richards

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Ceri,

External Zip binaries are not supported under Windows which is why you get those errors. - you can only specify an external binary on linux based servers....

one thing to try that might work though....put the zip.exe and unzip.exe files in a directory path that doesn't have spaces in it "Program Files" has a space which windows doesn't deal with very well when called via the command prompt.

try putting them somewhere like C:\zip\zip.exe and see if that works, otherwise you will just need to rely on the internal routines.

smile

Dan
Average of ratings: Useful (1)
In reply to Dan Marsden

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Ken Wilson -
External Zip binaries are not supported under Windows which is why you get those errors. - you can only specify an external binary on linux based servers....

Sorry Dan, but that's incorrect.

The function zip_files in lib/moodlelib.php specifically checks for Windows as an OS around line 7182 by adding the correct command separators, so the use of the GNU Win32 binaries looks like it is meant to be supported. The problem is that the list of files does not point to the directory where the files are stored. Here is a possible fix by the modification of code beginning from line 7176 in the file lib/moodlelib.php - code changes are shown in red:


The additions made are to get the driveletter where moodledata is stored and add this to the list of files to zip as a relative path. That way the windows zip binary knows where to look for its files.

Apologies to any developers reading this for the inelegant code wink, but it's worked for us on our Windows servers for the nearly 2 years, so if it ain't broke...

Ken

Average of ratings: Useful (2)
In reply to Ken Wilson

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Ceri Richards -
Thanks Ken - I'll definately give this a whirl!

Dan - I tried changing my zip install directory so there were no spaces, but still no joy sad Thanks anyway for trying!

Cheers,
Ceri
In reply to Ken Wilson

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Ceri Richards -
Hi Ken,

Many thanks but no cigar! sad

These are the changes I made - I even got one of our developers involved as my reading of PHP code isn't the best!!!

$filestozip = "";
$driveletter = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? substr($origpath,0,2) : ''; //Added KAW 2006-09-06 for Windows fix
foreach ($files as $filetozip) {
/* $filestozip .= escapeshellarg(basename($filetozip));
$filestozip .= " ";*/
//Changed KAW 2006-09-06 for Windows fix

$filestozip .= strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ?
escapeshellarg($driveletter.basename($filetozip)) : escapeshellarg(basename($filetozip));

//$filestozip .= escapeshellarg(basename($filetozip));

$filestozip .= " ";

Still get the same error. I've also taken Dan's feedback on board and switched our zip install to - D:\Zip\bin\zip.exe - still no joy.

Cheers,
Ceri
Average of ratings: Useful (1)
In reply to Ken Wilson

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
ok, well maybe we need to update documentation and lang strings? - but as far as I knew it didn't work smoothly with current core code... definitely interested in hearing how you get it to work! - will have a look at your hack later on! - is there a tracker item about it?

thanks,

smile

Dan
Average of ratings: Useful (1)
In reply to Dan Marsden

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Ceri Richards -
Hi All,

I'm re-posting as this has happened again, two weeks after the first occurance. This is definately down to the cron job running the site automated backups.

As mentioned, I am running automated backups as 12am and keeping 1 days worth. I am using the cron service. Running Moodle 1.8.2+, PHP 5.1.2 on Server 2003/IIS6.

I've rebooted the server and run the cron job again - it mentions at the start of the page - Checking backup status...RUNNING
No activity in last 30 minutes. Unlocking status

Then my backups run all over again. Any ideas? I have now ditched the cron service and gone with a scheduled task and also disabled statistics?

Any other advise? Would upgrading resolve this issue?

Thanks,
Ceri
In reply to Ceri Richards

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Mark Focas -
Hi,

The code that does IO in Moodle needs some improvement. It doesn't report errors correctly. i have had this problem, and it was because the disk quota on my web server had been exceded. Try checking to make sure you have enough disk space and try again.

mfocas
In reply to Ceri Richards

Re: All Backups Fail - An error occurred while copying the zip file to the course directory

by Hermer ROK -
Once I had similar problem when I changed from one server to another. All backups stopped during file compression.

It was because in the new web server (was apache and OS was linux), it was open_basedir restriction in effect and the executables, located on /usr/bin/ could not be executed.

I found the problem after selecting debugging info to list all warnings, and then i did a manual backup.

I hope it helps.