4

I use Spatie Laravel package I can take backup by running this command

php artisan backup:run

but I want to take back up form admin panel and running this command form controller, I create a route and controller and in the controller, I do this

public function backup(){
    \Artisan::call('backup:run');
    return "successfully!";
}

when I route to this finally I got the success message but in the backup file, nothing added.

apokryfos
  • 38,771
  • 9
  • 70
  • 114
Nasser Ali Karimi
  • 4,462
  • 6
  • 34
  • 77

1 Answers1

0

You can put artisan command in sheduler. It will make back up for example every day at the same time. You do it in app/console/Kernel.php

$schedule->command('backup:run')->daily();

Remember to set your server for cron jobs:

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

Read more: https://laravel.com/docs/5.6/scheduling

Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51