App\Console\Commands\SystemBackup Class Reference
Inheritance diagram for App\Console\Commands\SystemBackup:

Public Member Functions

 __construct ()
 Create a new command instance. More...
 
 fire ()
 Execute the console command. More...
 

Protected Attributes

 $name = 'snipeit:backup'
 
 $description = 'This command creates a database dump and zips up all of the uploaded files in the upload directories.'
 

Detailed Description

Definition at line 7 of file SystemBackup.php.

Constructor & Destructor Documentation

App\Console\Commands\SystemBackup::__construct ( )

Create a new command instance.

Returns
void

Definition at line 28 of file SystemBackup.php.

29  {
30  parent::__construct();
31  }

Member Function Documentation

App\Console\Commands\SystemBackup::fire ( )

Execute the console command.

Returns
mixed

Definition at line 38 of file SystemBackup.php.

39  {
40  //
41  $files['avatars'] = glob(public_path().'/uploads/avatars/*');
42  $files['models'] = glob(public_path().'/uploads/models/*');
43  $files['suppliers'] = glob(public_path().'/uploads/suppliers/*');
44  $files['private_uploads'] = glob(config('app.private_uploads').'/*');
45  $base_filename = date('Ymdgis');
46  $zip_file = config('app.private_uploads').'/backups/zips/'.$base_filename.'-backup.zip';
47  $db_dump = config('app.private_uploads').'/backups/sql/'.$base_filename.'-db.sql';
48  $this->call('db:backup', array('filename' => $db_dump));
49  echo $zip_file."\n";
50  echo $db_dump."\n";
51 
52 
53  Zipper::make($zip_file)
54  ->folder('avatars')->add($files['avatars'])
55  ->folder('models')->add($files['models'])
56  ->folder('suppliers')->add($files['suppliers'])
57  ->folder('private_uploads')->add($files['private_uploads'])
58  ->folder('database')->add($db_dump)->close();
59 
60  $this->info('Backup file created at '.$zip_file);
61  $this->info('Removing SQL dump at '.$db_dump);
62  unlink($db_dump);
63 
64  }

Member Data Documentation

App\Console\Commands\SystemBackup::$description = 'This command creates a database dump and zips up all of the uploaded files in the upload directories.'
protected

Definition at line 21 of file SystemBackup.php.

App\Console\Commands\SystemBackup::$name = 'snipeit:backup'
protected

Definition at line 14 of file SystemBackup.php.


The documentation for this class was generated from the following file: