Artisan::call('backup:run'); Not working
I'm trying to create backup from my system through Spatie Laravel Backup package.
And I'm calling artisan backup:run command from my controller Artisan::call('backup:run');. But its not working.
Can anyone please help me with this issue??
obviously I did.
and as they said php artisan backup:run working from cmd. but I want to do that from my controller using Artisan::call('backup:run'); this line.
Hi, @nikhil_lu210. If you have solved this, please let me know.
Can you run:
php artisan backup:run
It's worked from command promt. But I want to do this by my controller.
and its not working.
are you using php artisan serve as your webserver?
Thats your problem. the php internal webserver can only deal with a single request. Calling Artisan from within that request results in a hang whilst it waits for a second connection.
So you meant, it will not work here??
Is that will work on server??
Its not even working on my bluehost serve too....
Now what can I do...? @snapey
so how we can solve that
Why are you trying to run it this way?
What does "not even working" mean?
May be you didn't get my point. let me clear it to you.
Actually I have developed an application. And I want to take backup from my Super Admin section.
https://snipboard.io/1Ya04b.jpg
And that's why I need to do that. So I can create new backup by clicking on the button. @snapey
Then you have an error in your code to make it "not working"
But other commands are working fine.
/**
* Create New Backup
*/
public function create()
{
Artisan::call('backup:run');
toast('New Backup created successfully.', 'success')->autoClose(2000)->timerProgressBar();
return redirect()->back();
}
How can we help when you refuse to describe what "not working" means?
When I click on the Button "Create New Backup" it load sometime and after a certain time its redirect back with successful alert. but the backup does not created at all.
@nikhil_lu210 Any output in your error logs? storage/logs
No error
@nikhil_lu210 You can get the error message by using this
Route::get('/backup', function (Request $request) { Artisan::call('backup:run'); return Artisan::output(); });
Try running the command like this:
Artisan::queue('backup:run', ['--only-db' => true]);
And don't forget to run the command in queue mode:
php artisan queue:work
Try to check the output of artisan after you run it ->
Artisan::call('backup:run');
dd(Artisan::output());
And see what is the issue.
Try This, Go to Config Folder inside database.php update the following line
'dump' => [ 'dump_binary_path' => 'F:/kalpesh/mysql/bin/', <-- Here Add Your Path
and it's worked for me.
I created a GitHub issue facing the same problem: https:// github.com/spatie/laravel-backup/issues/1578
@codelone Unfortunately destroyed all credibility with
And its not just happened to me, 1000+ people are getting the same problem and have no solution for it, I already search the entire internet.
@codelone might be related to permissions. When you run from the command line, you are executing mysqldump as yourself. When running from the application, you are running mysqldump as your web server user
@codelone I did test it, it is working as expected, but now i see that you are using a really old version of package on windows, first upgrade to the latest version, add mysql path in environment variables of windows, also try disabling UAC
@Snapey that is the most common problem in linux, I don't know if the same thing will happen in windows
I found the solution now and I posted it here: https://stackoverflow.com/a/73929009/13804634
But going to post here too... I had invested a lot of time, particularly in this specific issue and found the solution in my case...as php artisan backup: run command successfully backups the database using CLI...so there is no issue with the package itself... I'm using "spatie/laravel-backup": "^6.16"
route/web.php create a route to test the artisan command
Route::get('/backup', function() { Artisan::call('backup:run'); }); As I can see when we try to launch the laravel application we use CLI for example:
php artisan serve then your project will host on 127.0.0.1:8080/project/ or any given port.
Instead, try to access the project directly from your localhost without artisan and then navigate to your project directory from the address bar localhost/project/backup now, it will generate a backup in storage/app/public/ directory.
Must try this if you tried everything...
Please or to participate in this conversation.