I have made a cron job for backing up my database.
When i run php artisan backup:database, I have an error showing that "App\Console\Commands\Storage" is missing.
I followed this video on youtube. And this video is 3 years back.
Can someone help me with this error. Or is there any other alternative to backup database?
Below is my code:
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
class DatabaseBackup extends Command
{
protected $signature = 'backup:database';
protected $description = 'This is to backup database';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$date = Carbon::now()->format('d/m/Y');
$user = env('DB_USERNAME');
$password = env('DB_PASSWORD');
$database = env('DB_DATABASE');
$command = "mysqldump --user={$user} -p{$password} {$database} > {$date}.sql";
$process = new Process($command);
$process->start();
while ($process->isRunning()) {
$public = Storage::disk('public');
$public->put('users/'.$date.".sql", file_get_contents("{$date}.sql"));
}
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LpOhXr
via IFTTT
Aucun commentaire:
Enregistrer un commentaire