Export db using mysqldump

Hi all,

I have in place a backup system (export/import) of the mysql database via php which works very well (apart from exeoutput).

  • My code for the export (in local)
    exec (“D:/web/xampp_56/mysql/bin/mysqldump --routines -h $dbhost -u $dbuser -p$dbpass --single-transaction $dbname > mvt/base1.sql.gz”);

  • My code for the import
    exec(“D:/web/xampp_56/mysql/bin/mysql -u $dbuser -p$dbpass $dbname2 < mvt/base1.sql.gz”);

I know from the documentation that the exec() shell_exec() and system() functions are ok in ExeOutput but I can’t make it work in the software (despite all my tweaks). I also tried to get the absolute path to mysqldump via $path = exo_getglobalvariable(‘HEPublicationPath’, ‘’).‘mysql/bin/mysqldump’; (may be wrong here) and use the $path variable in the exec() but the dump doesn’t work.

Anybody have an idea on how to make it work in exeoutput?

Best regards!

Fixed with a library that doesn’t require to fill in the full path to mysqldump : GitHub - ifsnop/mysqldump-php: PHP version of mysqldump cli that comes with MySQL

Regards!

2 Likes

Hey! Nice share. Going to add this to my tools library for future use.

1 Like