Skip to content

Commit 64dc07f

Browse files
Merge branch 'main' into 6.0
2 parents 11890c2 + ff912a0 commit 64dc07f

38 files changed

+455
-347
lines changed

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"ext-json": "*",
5050
"ext-spl": "*",
5151
"sebastian/environment": "^3.0|^4.0|^5.0",
52-
"sebastianfeldmann/cli": "^3.1",
53-
"phpmailer/phpmailer": "^6.0"
52+
"sebastianfeldmann/cli": "^3.4"
5453
},
5554
"require-dev": {
5655
"sebastianfeldmann/git": "^3.2",
@@ -66,7 +65,8 @@
6665
"php-opencloud/openstack": "^3.0",
6766
"arhitector/yandex": "^2.0",
6867
"microsoft/azure-storage-blob": "^1.4",
69-
"captainhook/captainhook": "^5.0"
68+
"captainhook/captainhook": "^5.0",
69+
"phpmailer/phpmailer": "^6.0"
7070
},
7171
"suggest": {
7272
"sebastianfeldmann/ftp": "Require ^0.9 to sync to an FTP server",
@@ -79,7 +79,8 @@
7979
"vlucas/phpdotenv": "Require ^3.0 or ^4.0 or ^5.0 to use the Dotenv adapter",
8080
"google/apiclient":"Require ^2.0 to sync to Google Drive",
8181
"arhitector/yandex":"Require ^2.0 to sync to Yandex Disk",
82-
"microsoft/azure-storage-blob": "Require ^1.4 to sync to Azure Blob Storage"
82+
"microsoft/azure-storage-blob": "Require ^1.4 to sync to Azure Blob Storage",
83+
"phpmailer/phpmailer": "Require ^6.0 to receive logs via email"
8384
},
8485
"bin": [
8586
"phpbu"

phive.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.5.0"/>
4-
<phar name="phpab" version="^1.20.0" location="./tools/phpab" copy="true" installed="1.26.0"/>
5-
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.5.8"/>
6-
<phar name="phpstan" version="^0.12.2" location="./tools/phpstan" copy="true" installed="0.12.67"/>
3+
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.5.9"/>
4+
<phar name="phpab" version="^1.20.0" location="./tools/phpab" copy="true" installed="1.26.3"/>
5+
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.6.0"/>
6+
<phar name="phpstan" version="^0.12.2" location="./tools/phpstan" copy="true" installed="0.12.99"/>
77
</phive>

src/Backup/Crypter/OpenSSL.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public function crypt(Target $target, Result $result)
100100

101101
$result->warn($name . ': The ' . $this->algorithm . ' algorithm is considered weak');
102102
}
103+
if ($target->getSize() > 1610612736) {
104+
throw new Exception('Backup to big to encrypt: OpenSSL SMIME can only encrypt files smaller 1.5GB.');
105+
}
103106
parent::crypt($target, $result);
104107
}
105108

@@ -121,7 +124,7 @@ public function simulate(Target $target, Result $result)
121124
* Is the configured cipher secure enough
122125
*
123126
* @return bool
124-
* @throws \phpbu\App\Backup\Crypter\Exception
127+
* @throws Exception
125128
*/
126129
public function isUsingWeakAlgorithm(): bool
127130
{
@@ -170,8 +173,8 @@ public function getSuffix() : string
170173
/**
171174
* Decrypt the backup
172175
*
173-
* @param \phpbu\App\Backup\Target $target
174-
* @param \phpbu\App\Backup\Restore\Plan $plan
176+
* @param Target $target
177+
* @param Plan $plan
175178
* @throws \phpbu\App\Exception
176179
*/
177180
public function restore(Target $target, Plan $plan)
@@ -183,8 +186,8 @@ public function restore(Target $target, Plan $plan)
183186
/**
184187
* Create the Executable to run the 'mcrypt' command
185188
*
186-
* @param \phpbu\App\Backup\Target $target
187-
* @return \phpbu\App\Cli\Executable
189+
* @param Target $target
190+
* @return Executable
188191
* @throws \phpbu\App\Exception
189192
*/
190193
protected function createExecutable(Target $target) : Executable
@@ -195,8 +198,8 @@ protected function createExecutable(Target $target) : Executable
195198
/**
196199
* Create encryption OpenSSL
197200
*
198-
* @param \phpbu\App\Backup\Target $target
199-
* @return \phpbu\App\Cli\Executable\OpenSSL
201+
* @param Target $target
202+
* @return Executable\OpenSSL
200203
* @throws \phpbu\App\Exception
201204
*/
202205
private function createEncryptionOpenSSL(Target $target): Executable\OpenSSL
@@ -211,8 +214,8 @@ private function createEncryptionOpenSSL(Target $target): Executable\OpenSSL
211214
/**
212215
* Create decryption OpenSSL
213216
*
214-
* @param \phpbu\App\Backup\Target $target
215-
* @return \phpbu\App\Cli\Executable\OpenSSL
217+
* @param Target $target
218+
* @return Executable\OpenSSL
216219
* @throws \phpbu\App\Exception
217220
*/
218221
private function createDecryptionOpenSSL(Target $target): Executable\OpenSSL
@@ -227,8 +230,8 @@ private function createDecryptionOpenSSL(Target $target): Executable\OpenSSL
227230
/**
228231
* Setup an OpenSSL executable only thing missing is the decision of en or decryption
229232
*
230-
* @param \phpbu\App\Backup\Target $target
231-
* @return \phpbu\App\Cli\Executable\OpenSSL
233+
* @param Target $target
234+
* @return Executable\OpenSSL
232235
* @throws \phpbu\App\Exception
233236
*/
234237
private function createOpenSSL(Target $target): Executable\OpenSSL

src/Backup/Source/Mongodump.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class Mongodump extends SimulatorExecutable implements Simulator
3535
*/
3636
private $useIPv6;
3737

38+
/**
39+
* Uri to connect to
40+
* --uri <uri>
41+
*
42+
* @var string
43+
*/
44+
private $uri;
45+
3846
/**
3947
* Host to connect to
4048
* --host <hostname:port>
@@ -113,6 +121,8 @@ public function setup(array $conf = [])
113121

114122
$this->pathToMongodump = Util\Arr::getValue($conf, 'pathToMongodump', '');
115123
$this->useIPv6 = Util\Str::toBoolean(Util\Arr::getValue($conf, 'ipv6', ''), false);
124+
125+
$this->setupValidation();
116126
}
117127

118128
/**
@@ -137,12 +147,32 @@ protected function setupSourceData(array $conf)
137147
*/
138148
protected function setupCredentials(array $conf)
139149
{
150+
$this->uri = Util\Arr::getValue($conf, 'uri', '');
140151
$this->host = Util\Arr::getValue($conf, 'host', '');
141152
$this->user = Util\Arr::getValue($conf, 'user', '');
142153
$this->password = Util\Arr::getValue($conf, 'password', '');
143154
$this->authenticationDatabase = Util\Arr::getValue($conf, 'authenticationDatabase', '');
144155
}
145156

157+
/**
158+
* Validate source setup
159+
*
160+
* @throws \phpbu\App\Exception
161+
*/
162+
protected function setupValidation()
163+
{
164+
if (empty($this->uri)) {
165+
return;
166+
}
167+
168+
// If uri is set, cannot set other configurations
169+
foreach (['user', 'host', 'password', 'authenticationDatabase', 'databases'] as $attr) {
170+
if (!empty($this->{$attr})) {
171+
throw new Exception("cannot specify $attr and uri");
172+
}
173+
}
174+
}
175+
146176
/**
147177
* Execute the backup.
148178
*
@@ -177,6 +207,7 @@ protected function createExecutable(Target $target) : Executable
177207
$executable = new Executable\Mongodump($this->pathToMongodump);
178208
$executable->dumpToDirectory($this->getDumpDir($target))
179209
->useIpv6($this->useIPv6)
210+
->useUri($this->uri)
180211
->useHost($this->host)
181212
->credentials($this->user, $this->password, $this->authenticationDatabase)
182213
->dumpDatabases($this->databases)

src/Cli/Executable/Mongodump.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class Mongodump extends Abstraction implements Executable
3636
*/
3737
private $useIPv6;
3838

39+
/**
40+
* Uri to connect to
41+
* --uri <uri>
42+
*
43+
* @var string
44+
*/
45+
private $uri;
46+
3947
/**
4048
* Host to connect to
4149
* --host <hostname:port>
@@ -135,6 +143,18 @@ public function useIpv6(bool $bool) : Mongodump
135143
return $this;
136144
}
137145

146+
/**
147+
* Set uri to dump from
148+
*
149+
* @param string $uri
150+
* @return \phpbu\App\Cli\Executable\Mongodump
151+
*/
152+
public function useUri(string $uri) : Mongodump
153+
{
154+
$this->uri = $uri;
155+
return $this;
156+
}
157+
138158
/**
139159
* Set host to dump from.
140160
*
@@ -228,6 +248,7 @@ protected function createCommandLine() : CommandLine
228248

229249
$cmd->addOption('--out', $this->dumpDir, ' ');
230250
$cmd->addOptionIfNotEmpty('--ipv6', $this->useIPv6, false);
251+
$cmd->addOptionIfNotEmpty('--uri', $this->uri, true, ' ');
231252
$cmd->addOptionIfNotEmpty('--host', $this->host, true, ' ');
232253
$cmd->addOptionIfNotEmpty('--username', $this->user, true, ' ');
233254
$cmd->addOptionIfNotEmpty('--password', $this->password, true, ' ');

0 commit comments

Comments
 (0)