-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73c3a9a
commit cee2298
Showing
9 changed files
with
89 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Config/core.php | ||
Config/database.php | ||
tmp/* | ||
webroot/backps_dir/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
<?php | ||
class BackupsController extends AppController { | ||
public function index() { | ||
$bkps = array(); | ||
if ($handle = opendir(WWW_ROOT.'/backups_dir')) { | ||
/* This is the correct way to loop over the directory. */ | ||
while (false !== ($entry = readdir($handle))) { | ||
array_push($bkps, array('arquivo'=>$entry,'tam'=>0)); | ||
} | ||
closedir($handle); | ||
} | ||
$this->set('backups', $bkps); | ||
} | ||
} | ||
|
||
public function gerar_arq() { | ||
exec('tar cf '.WWW_ROOT.'/backups_dir/arq_'.date('Y_m_d_H_i_s').'.tar.gz '.ROOT, $saida); | ||
$this->redirect('/backups'); | ||
} | ||
|
||
public function gerar_db() { | ||
App::uses('ConnectionManager', 'Model'); | ||
$dataSource = ConnectionManager::getDataSource('default'); | ||
$username = $dataSource->config['login']; | ||
$passw = $dataSource->config['password']; | ||
$host = $dataSource->config['host']; | ||
$database = $dataSource->config['database']; | ||
//echo 'mysqldump -h '.$host.' -u '.$username.' -p'.$passw.' '.$database.' > '.WWW_ROOT.'/backups_dir/db_'.date('Y_m_d_H_i_s').'.tar.gz '; | ||
exec('mysqldump -h '.$host.' -u '.$username.' -p'.$passw.' '.$database.' > '.WWW_ROOT.'/backups_dir/db_'.date('Y_m_d_H_i_s').'.tar.gz ', $saida, $status); | ||
pr($status); | ||
//$this->redirect('/backups'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
Backups | ||
<div class="row"> | ||
<div class="page-header"> | ||
<h3>Backups</h3> | ||
</div> | ||
<table class="table table-bordered"> | ||
<tr> | ||
<th>Arquivo</th> | ||
<th>Tamanho</th> | ||
</tr> | ||
<?php foreach($backups as $bkp) { | ||
if (strstr($bkp['arquivo'], 'tar.gz')) { ?> | ||
<tr> | ||
<td><a href="<?php echo '/backups_dir/'.$bkp['arquivo']; ?>"><?php echo $bkp['arquivo']; ?></a></td> | ||
<td><?php echo number_format( (filesize(WWW_ROOT.'/backups_dir/'.$bkp['arquivo'])/1024/1024) ) .' MB';?></td> | ||
</tr> | ||
<?php } } ?> | ||
</table> | ||
<div class="form-actions"> | ||
<a class="btn btn-danger" href="/backups/gerar_arq">Novo Backup Arquivos</a> | ||
<a class="btn btn-danger" href="/backups/gerar_db">Novo Backup Banco</a> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.