mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 09:05:46 +00:00
IMPR: Add create MySQL dump task
This commit is contained in:
parent
395266963c
commit
31b890cd85
26
src/Tasks/DumpMySQL.php
Executable file
26
src/Tasks/DumpMySQL.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace A2nt\CMSNiceties\Tasks;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
use SilverStripe\ORM\DB;
|
||||
|
||||
class DumpMySQL extends BuildTask
|
||||
{
|
||||
protected $title = 'Dump MySQL Task';
|
||||
protected $description = 'Create MySQL dump';
|
||||
protected $enabled = true;
|
||||
|
||||
public function run($request)
|
||||
{
|
||||
$cfg = DB::getConfig();
|
||||
|
||||
ob_clean();
|
||||
|
||||
header('Content-Disposition: attachment; filename="backup-'.date('d-m-Y').'.sql"');
|
||||
passthru('mysqldump -u '.$cfg['username'].' --password="'.$cfg['password'].'" '.$cfg['database']);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user