0

I have installed sepatie/backup package on my project and configure to create mysql backup. This work when i run php artisan backup:run. But what i am trying to do is to let user freedom to create backup by clickin on a button. So i have done something like this

Route::get('backup-run', function() {
    Artisan::call('backup:run');
    return response()->json(['success' => 'Backup for database created']);
});

and a button with vue js method

createDBBackup() {
            axios.get('/backup-run')
            .then(response => {

on database.php i have add this config i found on documentation

            'dump' => [
                'dump_binary_path' => 'C:\xampp\mysql\bin', // only the path, so without `mysqldump` or `pg_dump`
                'use_single_transaction',
                'timeout' => 60 * 5, // 5 minute timeout
            ],

as response i get some error like this on clockwork

Spatie\Backup\Events\BackupHasFailed exception: Spatie\DbDumper\Exceptions\DumpFailedbackupDestination: null
exception: Spatie\DbDumper\Exceptions\DumpFailed
*message: "The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 2004: "Can't create TCP/IP socket (10106)" when trying to connect
"
~string: ""
*code: 0
*file: "C:\...\vendor\spatie\db-dumper\src\Exceptions\DumpFailed.php"
*line: 17
~trace: Array(79)
~previous: null
backupDestination: null
Maison012
  • 99
  • 1
  • 9
  • Is this helpful? https://stackoverflow.com/questions/52718284/misuse-of-shell-builtins-mysqldump-got-error-2004-cant-create-tcp-ip-sock/73929009#73929009 – Gicu Aftene Nov 29 '22 at 08:37
  • I cant migrate to project to xamp couse i need to change many things like route and some paths. But also as mysql server i use `mysql workbranch` on my pc – Maison012 Nov 29 '22 at 08:39
  • @GicuAftene This is not working for me – Maison012 Nov 29 '22 at 11:29
  • MySql Workbench it's not a mysql server it's only a UI for query relational db servers. BTW your error seems to be a *permission problem* because your php backend can't execute a mysql_dump command on shell with the right privileges in order to open the requested port. – Gicu Aftene Nov 29 '22 at 12:14
  • if you run php artisan backup:run it runs with your privileges but when it runs over an http request with an apache http server or what else that command runs with inherited privileges of the web server or from privileges that are specified in config of your web server. – Gicu Aftene Nov 29 '22 at 12:26
  • Do you use `php artisan serve` or do you use the web server config? – Gicu Aftene Nov 29 '22 at 12:29
  • I use `php artisan serve` to run my project. `it runs with your privileges but when it runs over an http...` i understand but what should i do to make this hapend. How can i give permission my laravel project to read mysql dump folder? – Maison012 Nov 29 '22 at 13:07
  • @GicuAftene How should i give my system permission to read mysql dump folder from my pc? – Maison012 Nov 29 '22 at 15:34
  • If you're in a windows enviroment just change folder permissions a more permissive – Gicu Aftene Nov 29 '22 at 15:38
  • @GicuAftene if you mean change folder permission to `full access` it does not work. I have tryed – Maison012 Nov 29 '22 at 16:14

0 Answers0