Skip to content

Instantly share code, notes, and snippets.

@cotcotquedec
Last active July 19, 2016 06:42
Show Gist options
  • Save cotcotquedec/3332d08298429a3afc05c38735a3a42c to your computer and use it in GitHub Desktop.
Save cotcotquedec/3332d08298429a3afc05c38735a3a42c to your computer and use it in GitHub Desktop.
Commande laravel pour effectuer un backup de la base en locale et sur dropbox.
<?php
namespace App\Console\Commands;
use BackupManager\Filesystems\Destination;
use Illuminate\Console\Command;
/**
* @link https://github.com/backup-manager/backup-manager
* @link https://github.com/backup-manager/laravel
*
* lancer les commandes suivantes :
* $ > composer require backup-manager/laravel
* $ > composer require league/flysystem-dropbox
*
*/
class Backup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backup';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Création de backups pour la plateforme';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
/** @var \BackupManager\Manager $manager */
$manager = app()->make(\BackupManager\Manager::class);
$destination = sprintf('mysql_%s.sql', date('Y_m_d__H_i'));
$manager->makeBackup()->run('mysql', [
new Destination('local', $destination),
new Destination('dropbox', $destination)
], 'gzip');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment