|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Description of BackupLocal
|
|
|
|
|
*
|
|
|
|
|
* @author Victor
|
|
|
|
|
*/
|
|
|
|
|
final class BackupLocal extends AbstractLocalLan {
|
|
|
|
|
|
|
|
|
|
public function __destruct() {
|
|
|
|
|
$this->Debug(self::$BACKUP_FINALIZADO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Connect(BackupInfo $backup) {
|
|
|
|
|
$this->backup = $backup;
|
|
|
|
|
$this->Debug("Iniciando processo de backup");
|
|
|
|
|
if (!file_exists($this->backup->dir)) {
|
|
|
|
|
$this->Error("O diret<EFBFBD>rio de destino '{$this->backup->dir}' n<EFBFBD>o existe");
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!is_dir($this->backup->dir)) {
|
|
|
|
|
$this->Error("O destino '{$this->backup->dir}' n<EFBFBD>o <EFBFBD> um diret<EFBFBD>rio v<EFBFBD>lido!");
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->Debug("Diret<EFBFBD>rio '{$this->backup->dir}' encontrado");
|
|
|
|
|
$this->_handler = $this->backup->dir;
|
|
|
|
|
$this->backup->dirAtual = $this->backup->dir;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Upload(array $dadosArquivo, $remoteFile) {
|
|
|
|
|
$localFile = $dadosArquivo['file'];
|
|
|
|
|
$hash = $dadosArquivo['hash'];
|
|
|
|
|
$cmd = sprintf("cp -u %s %s%s", $localFile, $this->backup->dirAtual, $remoteFile);
|
|
|
|
|
$debugMsg = sprintf("Iniciando c<EFBFBD>pia do arquivo '%s' para '%s%s%s'...", $localFile, $this->GetInfo('host'), $this->GetInfo('dir'), $remoteFile);
|
|
|
|
|
$this->Debug($debugMsg);
|
|
|
|
|
$result = $this->sys($cmd);
|
|
|
|
|
if (!file_exists(sprintf("%s%s", $this->backup->dirAtual, $remoteFile))) {
|
|
|
|
|
$this->Error("N<EFBFBD>o foi poss<EFBFBD>vel gravar o arquivo remoto!");
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->Debug("C<EFBFBD>pia conclu<EFBFBD>do com sucesso");
|
|
|
|
|
|
|
|
|
|
return $this->CheckHash($hash, $this->backup->dirAtual . $remoteFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|