| @@ 56-74 (lines=19) @@ | ||
| 53 | * @param \phpbu\App\Result $result |
|
| 54 | * @throws \phpbu\App\Backup\Sync\Exception |
|
| 55 | */ |
|
| 56 | public function sync(Target $target, Result $result) |
|
| 57 | { |
|
| 58 | $this->client = $this->createClient(); |
|
| 59 | ||
| 60 | if (!$this->client->doesBucketExist($this->bucket)) { |
|
| 61 | $result->debug('create s3 bucket'); |
|
| 62 | $this->createBucket($this->client); |
|
| 63 | } |
|
| 64 | ||
| 65 | try { |
|
| 66 | $this->upload($target, $this->client); |
|
| 67 | $result->debug('upload: done'); |
|
| 68 | ||
| 69 | // run remote cleanup |
|
| 70 | $this->cleanup($target, $result); |
|
| 71 | } catch (\Exception $e) { |
|
| 72 | throw new Exception($e->getMessage(), null, $e); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Create the AWS client. |
|
| @@ 121-139 (lines=19) @@ | ||
| 118 | * @param \phpbu\App\Result $result |
|
| 119 | * @throws \phpbu\App\Backup\Sync\Exception |
|
| 120 | */ |
|
| 121 | public function sync(Target $target, Result $result) |
|
| 122 | { |
|
| 123 | $this->client = $this->createClient(); |
|
| 124 | ||
| 125 | if (!$this->doesContainerExist($this->client, $this->containerName)) { |
|
| 126 | $result->debug('create blob container'); |
|
| 127 | $this->createContainer($this->client); |
|
| 128 | } |
|
| 129 | ||
| 130 | try { |
|
| 131 | $this->upload($target, $this->client); |
|
| 132 | $result->debug('upload: done'); |
|
| 133 | ||
| 134 | // run remote cleanup |
|
| 135 | $this->cleanup($target, $result); |
|
| 136 | } catch (\Exception $e) { |
|
| 137 | throw new Exception($e->getMessage(), null, $e); |
|
| 138 | } |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * Create the Azure Blob client. |
|