Fix #238 - database backup not working

This commit is contained in:
Ivan Diaz 2018-07-02 15:36:06 -03:00
parent 0a88bbccd6
commit cd16026f31
1 changed files with 3 additions and 8 deletions

View File

@ -14,7 +14,7 @@ use Ifsnop\Mysqldump as IMysqldump;
* @apiPermission staff3
*
* @apiUse NO_PERMISSION
*
*
* @apiSuccess {File} file File of the backup
*
*/
@ -31,19 +31,14 @@ class BackupDatabaseController extends Controller {
}
public function handler() {
global $mysql_host;
global $mysql_database;
global $mysql_user;
global $mysql_password;
$fileDownloader = FileDownloader::getInstance();
$fileDownloader->setFileName('backup.sql');
$mysqlDump = new IMysqldump\Mysqldump('mysql:host='. $mysql_host .';dbname=' . $mysql_database, $mysql_user, $mysql_password);
$mysqlDump = new IMysqldump\Mysqldump('mysql:host='. MYSQL_HOST . ';port=' . MYSQL_PORT . ';dbname=' . MYSQL_DATABASE , MYSQL_USER, MYSQL_PASSWORD);
$mysqlDump->start($fileDownloader->getFullFilePath());
if($fileDownloader->download()) {
$fileDownloader->eraseFile();
}
}
}
}