Error on CLI Course Backup

Error on CLI Course Backup

by Shamiso Jaravaza -
Number of replies: 4

I'm trying to run the CLI Backup command on Windows 10 in command prompt. But I get the following error:

<p>Error: database driver problem detected</p>

<p>The site administrator should verify server configuration</p><p>PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP.</p> !!!

I'm running Moodle on localhost using a Bitnami Stack (MariaDB 10.4.20, Moodle 3.11.2, PHP 7.4.21, Apache 2.4.48)

I noticed my supervisor does this, so to get around using cmd I run the following as a bat file from within the cli folder:

@echo on
c:\bitnami\moodle-3.11.2-0\php\php.exe -f c:\bitnami\moodle-3.11.2-0\apps\moodle\htdocs\admin\cli\backup.php -courseid=4 

When I use this method for cron.php and other backup cli commands it works, and doing a backup within Moodle also works. I can't figure out what I'm doing wrong. Could somebody help me please?




Average of ratings: -
In reply to Shamiso Jaravaza

Re: Error on CLI Course Backup

by Ken Task -
Picture of Particularly helpful Moodlers

Not a Windows person ... but ...

look at the backup.php script itself ... all cli only scripts have require lines:

In backup.php

require(__DIR__.'/../../config.php');

Scripts will use variables found in config.php ... like DB Driver.

Is c:\bitnami\moodle-3.11.2-0\php\php.exe the same as php-cli or is it the same php that runs the web?

'SoS', Ken


In reply to Ken Task

Re: Error on CLI Course Backup

by Shamiso Jaravaza -
Success! I've found what the problem was. Within the script I was running, there was the -f argument that I wasn't even sure was doing anything. For anybody with a unique case like this, the bat file should look like this (create a log subfolder and file in the directory if you want a log file!)

@echo on
c:\bitnami\moodle-3.11.2-0\php\php.exe c:\bitnami\moodle-3.11.2-0\apps\moodle\htdocs\admin\cli\backup.php --courseid=4 > c:\bitnami\moodle-3.11.2-0\logs\backup.log

Not sure why some commands work but others don't when -f is included as I'm no cmd guru. Now my issue is I am not seeing the .mbz file that should have been created. It is showing up in Moodle in the course restore section, but I can't seem to find it in any of the moodledata subfolders. I have checked the config.php and it should be in the default backup location (which is C:/Bitnami/MOODLE~1.2-0/apps/moodle/moodledata). Any suggestions?

Also thank you for helping!
In reply to Shamiso Jaravaza

Re: Error on CLI Course Backup

by Ken Task -
Picture of Particularly helpful Moodlers

there is an additional option at end of command - before your redirect > to log.

--destination="C:\whereever\" ... has to be manually created and writable by user/webservice.

Backup files in moodledata/filedir/ are not humanly recognizable by filename.ext, but, rather, are given the value of the contenthash in mdl_files table.

'SoS', Ken