Add backup FROM SFTP to local

This commit is contained in:
2020-04-16 17:57:14 +02:00
parent c18d517afb
commit 0952cf2db3
9 changed files with 184 additions and 17 deletions

View File

@@ -29,19 +29,25 @@ class Folder extends TransportAbstract
*/
public function send()
{
foreach ($this->backup->getFilesToBackup() as $file => $name) {
if (copy($file, $this->folder . $name) === false) {
throw new \Exception(sprintf('Copy of %s in %s failed', $name, $this->folder));
};
if ($this->backup->isDistant()) {
$this->backup = $this->backup->retrieve();
}
foreach ($this->backup->getStreamsToBackup() as $name => $file) {
if (substr_count($name, '.') + 1 < 2) {
$name = 'backup' . $name . '.txt';
if ($this->backup->isLocal()) {
foreach ($this->backup->getFilesToBackup() as $file => $name) {
if (copy($file, $this->folder . $name) === false) {
throw new \Exception(sprintf('Copy of %s in %s failed', $name, $this->folder));
}
}
if (file_put_contents($this->folder . $name, $file) === false) {
throw new \Exception(sprintf('Saving of %s in %s failed', $name, $this->folder));
foreach ($this->backup->getStreamsToBackup() as $name => $file) {
if (substr_count($name, '.') + 1 < 2) {
$name = 'backup' . $name . '.txt';
}
if (file_put_contents($this->folder . $name, $file) === false) {
throw new \Exception(sprintf('Saving of %s in %s failed', $name, $this->folder));
}
}
}
return true;
}
}