Automatic backup not working in Laravel with Spatie

866 views Asked by At

I'm trying to run backup using cron, i'm using spatie-laravel-backup it is working when i run it manually but when i run it using cron using this path on server:

/home/user/public_html && php artisan backup:run >> /home/user/logs 2>&1     

and i'm getting this

/bin/bash: /home/user/public_html: Is a directory"

kernel.php

 protected function schedule(Schedule $schedule)
    {
     $schedule->command('backup:run')->daily()->at('10:00');
    }
1

There are 1 answers

5
Kamlesh Paul On

run scheduler from cron

https://laravel.com/docs/8.x/scheduling#running-the-scheduler

* * * * * cd /home/user/public_html && php artisan schedule:run >> /dev/null 2>&1

then

you can use

protected function schedule(Schedule $schedule)
{
   $schedule->command('backup:run')->daily()->at('10:00');
}