This method helps to export full database. See below example
// Download file
$DBImExport = App::Module('DBImExport');
$DBImExport->file_name = 'mybackup'; // .sql extension automatically add in file
$DBImExport->download = true;
$result = App::Module('DBImExport')->Export();
// Save file in a location
$DBImExport = App::Module('DBImExport');
$DBImExport->file_name = 'mybackup'; // .sql extension automatically add in file
$DBImExport->download_path = App::baseDir("/uploads/");
$result = App::Module('DBImExport')->Export();