Spatie Laravel Backup - sh: mysqldump: command not found
This is a super quick brain dump to document how I solved my problem with running backup commands from Spatie's Laravel-Backup package on the front end.
The Problem
One of the software projects I am working on uses the fantastic Laravel-Backup packages from Spatie.
Within this application, there is a need to run on-demand backups from the web interface. When calling Laravel's Artisan::call() method, I ran into the following error:
sh: mysqldump: command not found
The Solution
If you run into this issue and you have ruled out that you have mysql/mariadb installed and running and you can find the binary with a:
which mysqldump
You just need to add the path to the binary with the following config change in your config/database.php file:
'mariadb' => [
...
'dump' => [
'dump_binary_path' => env("DUMP_BINARY_PATH"),
]
]
Where the DUMP_BINARY_PATH environment variable points to your mysqldump path. In my case, it was
opt/homebrew/opt/mariadb@10.11/bin
NOTE: Just include the path to the binary, not the binary itself.
Success! You should now be able to run the command from your web interface.