@@ -1,12 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace phpbu\App\Backup\Sync; |
| 3 | 3 | |
| 4 | -use phpbu\App\Backup\File\Remote; |
|
| 5 | 4 | use phpbu\App\Result; |
| 6 | 5 | use phpbu\App\Backup\Sync; |
| 7 | 6 | use phpbu\App\Backup\Target; |
| 8 | 7 | use phpbu\App\Util\Arr; |
| 9 | -use phpbu\App\Util\Str; |
|
| 10 | 8 | |
| 11 | 9 | /** |
| 12 | 10 | * Ftp sync |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace phpbu\App\Backup\Sync; |
| 3 | 3 | |
| 4 | 4 | use phpbu\App\Backup\Cli; |
| 5 | -use phpbu\App\Backup\File\Remote; |
|
| 6 | 5 | use phpbu\App\Backup\Rsync as RsyncTrait; |
| 7 | 6 | use phpbu\App\Backup\Target; |
| 8 | 7 | use phpbu\App\Cli\Executable; |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace phpbu\App\Backup\Sync; |
| 3 | 3 | |
| 4 | -use phpbu\App\Backup\File\Remote; |
|
| 5 | 4 | use phpbu\App\Result; |
| 6 | 5 | use phpbu\App\Backup\Sync; |
| 7 | 6 | use phpbu\App\Backup\Target; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | // check for mandatory options |
| 75 | 75 | foreach (['user', 'secret', 'container', 'host', 'path'] as $option) { |
| 76 | 76 | if (!Arr::isSetAndNotEmptyString($config, $option)) { |
| 77 | - throw new Exception('SoftLayer ' . $option . ' is mandatory'); |
|
| 77 | + throw new Exception('SoftLayer '.$option.' is mandatory'); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | public function sync(Target $target, Result $result) |
| 99 | 99 | { |
| 100 | 100 | $sourcePath = $target->getPathname(); |
| 101 | - $targetPath = $this->path . $target->getFilename(); |
|
| 101 | + $targetPath = $this->path.$target->getFilename(); |
|
| 102 | 102 | |
| 103 | 103 | $options = ['adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 20]; |
| 104 | 104 | $objectStorage = new ObjectStorage($this->host, $this->user, $this->secret, $options); |
| 105 | 105 | |
| 106 | - $result->debug('softlayer source: ' . $sourcePath); |
|
| 107 | - $result->debug('softlayer target: ' . $targetPath); |
|
| 106 | + $result->debug('softlayer source: '.$sourcePath); |
|
| 107 | + $result->debug('softlayer target: '.$targetPath); |
|
| 108 | 108 | |
| 109 | 109 | try { |
| 110 | 110 | /** @var \ObjectStorage_Container $container */ |
| 111 | - $container = $objectStorage->with($this->container . $targetPath) |
|
| 111 | + $container = $objectStorage->with($this->container.$targetPath) |
|
| 112 | 112 | ->setLocalFile($sourcePath) |
| 113 | - ->setMeta('description', 'PHPBU Backup: ' . date('r', time())) |
|
| 113 | + ->setMeta('description', 'PHPBU Backup: '.date('r', time())) |
|
| 114 | 114 | ->setHeader('Content-Type', $target->getMimeType()); |
| 115 | 115 | $container->create(); |
| 116 | 116 | } catch (\Exception $e) { |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | public function simulate(Target $target, Result $result) |
| 130 | 130 | { |
| 131 | 131 | $result->debug( |
| 132 | - 'sync backup to SoftLayer' . PHP_EOL |
|
| 133 | - . ' host: ' . $this->host . PHP_EOL |
|
| 134 | - . ' user: ' . $this->user . PHP_EOL |
|
| 135 | - . ' secret: ********' . PHP_EOL |
|
| 136 | - . ' container: ' . $this->container . PHP_EOL |
|
| 137 | - . ' location: ' . $this->path |
|
| 132 | + 'sync backup to SoftLayer'.PHP_EOL |
|
| 133 | + . ' host: '.$this->host.PHP_EOL |
|
| 134 | + . ' user: '.$this->user.PHP_EOL |
|
| 135 | + . ' secret: ********'.PHP_EOL |
|
| 136 | + . ' container: '.$this->container.PHP_EOL |
|
| 137 | + . ' location: '.$this->path |
|
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -48,10 +48,10 @@ |
||
| 48 | 48 | } |
| 49 | 49 | /** @var \Kunnu\Dropbox\Models\FileMetadata $item */ |
| 50 | 50 | // skip currently created backup |
| 51 | - if ($item->getPathDisplay() == $this->path . $this->target->getFilename()) { |
|
| 51 | + if ($item->getPathDisplay() == $this->path.$this->target->getFilename()) { |
|
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | - if (preg_match('#' . $this->fileRegex . '#i', $item->getName())) { |
|
| 54 | + if (preg_match('#'.$this->fileRegex.'#i', $item->getName())) { |
|
| 55 | 55 | $this->files[] = new \phpbu\App\Backup\File\Dropbox($this->client, $item); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | if ($file->getPathname() == $this->target->getPathname()) { |
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | - if (preg_match('#' . $this->fileRegex . '#i', $file->getFilename())) { |
|
| 114 | - $index = date('YmdHis', $file->getMTime()) . '-' . $i . '-' . $file->getPathname(); |
|
| 113 | + if (preg_match('#'.$this->fileRegex.'#i', $file->getFilename())) { |
|
| 114 | + $index = date('YmdHis', $file->getMTime()).'-'.$i.'-'.$file->getPathname(); |
|
| 115 | 115 | $this->files[$index] = new FileLocal($file->getFileInfo()); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -140,6 +140,6 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $dirTarget = Arr::getValue($this->target->getChangingPathElements(), $depth); |
| 142 | 142 | $dirRegex = Str::datePlaceholdersToRegex($dirTarget); |
| 143 | - return preg_match('#' . $dirRegex . '#i', $dir); |
|
| 143 | + return preg_match('#'.$dirRegex.'#i', $dir); |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -52,10 +52,10 @@ |
||
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | 54 | // skip currently created backup |
| 55 | - if ($object->name == $this->path . $this->target->getFilename()) { |
|
| 55 | + if ($object->name == $this->path.$this->target->getFilename()) { |
|
| 56 | 56 | continue; |
| 57 | 57 | } |
| 58 | - if (preg_match('#' . $this->fileRegex . '#i', basename($object->name))) { |
|
| 58 | + if (preg_match('#'.$this->fileRegex.'#i', basename($object->name))) { |
|
| 59 | 59 | $this->files[] = new \phpbu\App\Backup\File\OpenStack($this->container, $object); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | $this->container = $container; |
| 24 | 24 | $this->filename = basename($object->name); |
| 25 | 25 | $this->pathname = $object->name; |
| 26 | - $this->size = (int)$object->contentLength; |
|
| 26 | + $this->size = (int) $object->contentLength; |
|
| 27 | 27 | $this->lastModified = $object->lastModified->getTimestamp(); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | if ($this->deleteTarget) { |
| 86 | 86 | $this->deleteTarget = false; |
| 87 | 87 | $result->debug('target will be deleted as well'); |
| 88 | - $result->debug('delete ' . $target->getPathname()); |
|
| 88 | + $result->debug('delete '.$target->getPathname()); |
|
| 89 | 89 | } |
| 90 | 90 | parent::simulate($target, $collector, $result); |
| 91 | 91 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | // should the currently created backup be deleted as well? |
| 140 | 140 | if ($this->deleteTarget) { |
| 141 | 141 | $file = $target->toFile(); |
| 142 | - $index = date('YmdHis', $file->getMTime()) . '-' . count($files) . '-' . $file->getPathname(); |
|
| 142 | + $index = date('YmdHis', $file->getMTime()).'-'.count($files).'-'.$file->getPathname(); |
|
| 143 | 143 | $files[$index] = $file; |
| 144 | 144 | } |
| 145 | 145 | return $files; |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | if ($fileInfo['filename'] == $this->target->getFilename()) { |
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | - if (preg_match('#' . $this->fileRegex . '#i', $fileInfo['filename'])) { |
|
| 54 | + if (preg_match('#'.$this->fileRegex.'#i', $fileInfo['filename'])) { |
|
| 55 | 55 | $this->files[] = new \phpbu\App\Backup\File\Sftp($this->sftp, $fileInfo, $this->path); |
| 56 | 56 | } |
| 57 | 57 | } |