Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://motylpro.pl/kategoria-produktu/kosmetyka/
- //use Symfony\Component\Process\Process;
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Symfony\Component\Process\Process;
- use Symfony\Component\Process\Exception\ProcessFailedException;
- class BackupDatabase extends Command
- {
- protected $signature = 'db:backup';
- protected $description = 'Backup the database';
- protected $process;
- public function __construct()
- {
- parent::__construct();
- $this->process = new Process(sprintf(
- 'mysqldump -u%s -p%s %s > %s',
- config('database.connections.mysql.username'),
- config('database.connections.mysql.password'),
- config('database.connections.mysql.database'),
- storage_path('backups/backup.sql')
- ));
- }
- public function handle()
- {
- try {
- $this->process->mustRun();
- $this->info('The backup has been proceed successfully.');
- } catch (ProcessFailedException $exception) {
- $this->error('The backup process has been failed.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement