Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skoobi's avatar
Level 13

Spatie Backup and mysqldump

Hi. Im getting an error when backing up to an ftp server through a task schedule.

The error is ::

Exception message: The dump process failed with exitcode 127 : Command not found : sh: 1: /usr/bin/mysqldump: not found

Now i know its installed because, well I installed it and i can run it from /usr/bin/mysqldump and if i run the command to backup from ssh it also works fine. But when its scheduled it just keeps failing.

On my testing server which is an exact duplicate of the production server, it works perfectly!

Heres some of the code:::

Kernel.php

$schedule->command('backup:run --only-db')->everyThirtyMinutes()->environments(['production']); // set to 30min for testing...

config/database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
            'dump' => [
                'dump_binary_path' => '/usr/bin',
            ]
        ],

Any ideas. According to spatie its a server config issue but if I can run it via the command line on the server, surely it should work from the schedule...

Cheers

0 likes
6 replies
Dalma's avatar

Can you elaborate on " backing up to an ftp server through a task schedule"

skoobi's avatar
Level 13

Hi @dalma. Ye sure, In the config it has an array to specify a disk to backup to so

'destination' => [

         /*
          * The disk names on which the backups will be stored.
          */
         'disks' => [
             'local',
         ],
     ],

I have it set to ftp. and the connection is good and all works when running the backup via the console.

Dalma's avatar

Are you able to run this successfully from the command line:

php artisan backup:run
skoobi's avatar
Level 13

Ye that command works perfectly. This is what's confusing me!

Snapey's avatar

I assume you get this error when the cron job runs. What account is the cron running under and does it have rights to see the folder.

skoobi's avatar
Level 13

Hi @snapey. It's running under root. I'm presuming it has the correct rights to see the folder, its all set up using Forge. The rest of the crons work.

Please or to participate in this conversation.