Skip to content

Commit a8bad8e

Browse files
Merge branch 'main' into 6.0
2 parents 1ebb083 + 5b4bab1 commit a8bad8e

File tree

9 files changed

+70
-20
lines changed

9 files changed

+70
-20
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: php -v
2828

2929
- name : Install tooling
30-
run : GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 661E97400F658E25,5E6DDE998AB73B8E,51C67305FFC2E5C0,4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720,2DF45277AEF09A2F,2A8299CE842DD38C
30+
run : GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 661E97400F658E25,5E6DDE998AB73B8E,51C67305FFC2E5C0,4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720,2DF45277AEF09A2F,2A8299CE842DD38C,A978220305CD5C32
3131

3232
- name: Update composer
3333
run: composer self-update

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Get an in depth look into all the features and a short 'getting started' tutoria
1616
[![Code Coverage](https://scrutinizer-ci.com/g/sebastianfeldmann/phpbu/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sebastianfeldmann/phpbu/?branch=master)
1717
[![PHP Website](https://img.shields.io/website-up-down-green-red/https/phpbu.de.svg)](https://phpbu.de)
1818

19-
If you are not using php 8.0 or greater already you can still use phpbu version [6.0.20](https://phar.phpbu.de/phpbu-5.2.10.phar) \
19+
If you are not using php 8.0 or greater already you can still use phpbu version [6.0.20](https://phar.phpbu.de/phpbu-6.0.20.phar) \
2020
If you are not using php 7.2 or greater already you can still use phpbu version [5.2.10](https://phar.phpbu.de/phpbu-5.2.10.phar) \
2121
If you are behind php 7.0 you can still use phpbu version [4.0.10](https://phar.phpbu.de/phpbu-4.0.10.phar)
2222

phive.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="captainhook" version="^5.10" location="./tools/captainhook" copy="true" installed="5.19.2"/>
4-
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.6.15"/>
5-
<phar name="phpab" version="^1.20.0" location="./tools/phpab" copy="true" installed="1.29.0"/>
6-
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.8.0"/>
7-
<phar name="phpstan" version="^1.0" location="./tools/phpstan" copy="true" installed="1.10.50"/>
3+
<phar name="captainhook" version="^5.10" location="./tools/captainhook" copy="true" installed="5.23.0"/>
4+
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.6.19"/>
5+
<phar name="phpab" version="^1.20.0" location="./tools/phpab" copy="true" installed="1.29.1"/>
6+
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.10.1"/>
7+
<phar name="phpstan" version="^1.0" location="./tools/phpstan" copy="true" installed="1.11.2"/>
88
</phive>

src/Backup/Crypter/OpenSSL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function crypt(Target $target, Result $result)
107107

108108
$result->warn($name . ': The ' . $this->algorithm . ' algorithm is considered weak');
109109
}
110-
if ($target->getSize() > 1610612736) {
110+
if (!empty($this->certFile) && $target->getSize() > 1610612736) {
111111
throw new Exception('Backup to big to encrypt: OpenSSL SMIME can only encrypt files smaller 1.5GB.');
112112
}
113113
parent::crypt($target, $result);

src/Backup/Target/Compression/Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class Factory
2525
'gzip' => 'Gzip',
2626
'bzip2' => 'Bzip2',
2727
'xz' => 'Xz',
28-
'zip' => 'Zip'
28+
'zip' => 'Zip',
29+
'zstd' => 'Zstd'
2930
];
3031

3132
/**
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace phpbu\App\Backup\Target\Compression;
3+
4+
/**
5+
* Zstd
6+
*
7+
* @package phpbu
8+
* @subpackage Backup
9+
* @author Sebastian Feldmann <sebastian@phpbu.de>
10+
* @copyright Sebastian Feldmann <sebastian@phpbu.de>
11+
* @license https://opensource.org/licenses/MIT The MIT License (MIT)
12+
* @link http://phpbu.de/
13+
* @since Class available since Release 3.2.1
14+
*/
15+
class Zstd extends Abstraction
16+
{
17+
/**
18+
* Command name
19+
*
20+
* @var string
21+
*/
22+
protected $cmd = 'zstd';
23+
24+
/**
25+
* Suffix for compressed files
26+
*
27+
* @var string
28+
*/
29+
protected $suffix = 'zst';
30+
31+
/**
32+
* MIME type for compressed files
33+
*
34+
* @var string
35+
*/
36+
protected $mimeType = 'application/zstd';
37+
38+
/**
39+
* Can this compression compress piped output
40+
*
41+
* @var bool
42+
*/
43+
protected $pipeable = true;
44+
}

src/Cli/Executable/Tar.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ class Tar extends Abstraction implements Executable
9393
* @var array
9494
*/
9595
private static $availableCompressions = [
96-
'bzip2' => 'j',
97-
'gzip' => 'z',
98-
'xz' => 'J'
96+
'bzip2',
97+
'gzip',
98+
'xz',
99+
'zstd'
99100
];
100101

101102
/**
@@ -142,7 +143,7 @@ public function __construct(string $path = '')
142143
*/
143144
protected function getCompressionOption(string $compressor) : string
144145
{
145-
return $this->isCompressionValid($compressor) ? self::$availableCompressions[$compressor] : '';
146+
return $this->isCompressionValid($compressor) ? $compressor : '';
146147
}
147148

148149
/**
@@ -323,7 +324,11 @@ protected function createCommandLine() : CommandLine
323324
$tar->addOptionIfNotEmpty('-h', $this->dereference, false);
324325
$tar->addOptionIfNotEmpty('--force-local', $this->local, false);
325326
$tar->addOptionIfNotEmpty('--use-compress-program', $this->compressProgram);
326-
$tar->addOption('-' . (empty($this->compressProgram) ? $this->compression : '') . $create);
327+
if ($this->compression && empty($this->compressProgram)) {
328+
$tar->addOption('--' . $this->compression);
329+
}
330+
$tar->addOption('-' . $create);
331+
327332

328333
if ($this->isThrottled()) {
329334
$pv = new Cmd('pv');
@@ -452,7 +457,7 @@ private function validateSetup()
452457
*/
453458
public static function isCompressionValid(string $compression) : bool
454459
{
455-
return isset(self::$availableCompressions[$compression]);
460+
return in_array($compression, self::$availableCompressions);
456461
}
457462

458463
/**

tests/phpbu/Backup/Source/TarTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function testCompressedTarget()
361361
$exec = $tar->getExecutable($target);
362362

363363
$this->assertEquals(
364-
'"' . PHPBU_TEST_BIN . '/tar" -zcf \'/tmp/backup.tar.gz\' -C \''
364+
'"' . PHPBU_TEST_BIN . '/tar" --gzip -cf \'/tmp/backup.tar.gz\' -C \''
365365
. dirname(__DIR__) . '\' \''
366366
. basename(__DIR__) . '\'',
367367
$exec->getCommand()

tests/phpbu/Cli/Executable/TarTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function testCompressionGzip()
179179
$tar->archiveDirectory($dir)->archiveTo('/tmp/foo.tar.gz')->useCompression('gzip');
180180

181181
$this->assertEquals(
182-
'"' . PHPBU_TEST_BIN . '/tar" -zcf \'/tmp/foo.tar.gz\' -C \'' . $tarC . '\' \'' . $tarD . '\'',
182+
'"' . PHPBU_TEST_BIN . '/tar" --gzip -cf \'/tmp/foo.tar.gz\' -C \'' . $tarC . '\' \'' . $tarD . '\'',
183183
$tar->getCommand()
184184
);
185185
}
@@ -196,7 +196,7 @@ public function testCompressionBzip2()
196196
$tar->archiveDirectory($dir)->archiveTo('/tmp/foo.tar.bzip2')->useCompression('bzip2');
197197

198198
$this->assertEquals(
199-
'"' . PHPBU_TEST_BIN . '/tar" -jcf \'/tmp/foo.tar.bzip2\' -C \'' . $tarC . '\' \'' . $tarD . '\'',
199+
'"' . PHPBU_TEST_BIN . '/tar" --bzip2 -cf \'/tmp/foo.tar.bzip2\' -C \'' . $tarC . '\' \'' . $tarD . '\'',
200200
$tar->getCommand()
201201
);
202202
}
@@ -216,7 +216,7 @@ public function testThrottle()
216216
->throttle('1m');
217217

218218
$this->assertEquals(
219-
'"' . PHPBU_TEST_BIN . '/tar" -jc -C \'' . $tarC . '\' \'' . $tarD . '\''
219+
'"' . PHPBU_TEST_BIN . '/tar" --bzip2 -c -C \'' . $tarC . '\' \'' . $tarD . '\''
220220
. ' | "pv" -qL \'1m\' > /tmp/foo.tar.bzip2',
221221
$tar->getCommand()
222222
);
@@ -238,7 +238,7 @@ public function testThrottleAndRemoveSourceDir()
238238
->throttle('1m');
239239

240240
$this->assertEquals(
241-
'("' . PHPBU_TEST_BIN . '/tar" -jc -C \'' . $tarC . '\' \'' . $tarD . '\''
241+
'("' . PHPBU_TEST_BIN . '/tar" --bzip2 -c -C \'' . $tarC . '\' \'' . $tarD . '\''
242242
. ' && "rm" -rf \'' . $dir . '\')'
243243
. ' | "pv" -qL \'1m\' > /tmp/foo.tar.bzip2',
244244
$tar->getCommand()

0 commit comments

Comments
 (0)