fix(backup): use shared compression for database dumps

Centralize compressor selection and apply helper-image compression to dump-all database backups.
This commit is contained in:
Andras Bacsai
2026-08-15 15:51:11 +02:00
parent 909e776fbc
commit 0a6db15216
5 changed files with 106 additions and 15 deletions
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Support;
final class BackupCompression
{
public static function cpuPercentage(int|string|null $configuredPercentage): int
{
$percentage = (int) $configuredPercentage;
return in_array($percentage, [25, 50, 75, 100], true) ? $percentage : 25;
}
public static function compressorCommand(int $cpuPercentage): string
{
$cpuPercentage = self::cpuPercentage($cpuPercentage);
return "if command -v pigz >/dev/null 2>&1; then printf 'pigz -3 -p %s' \"\$(( (\$(nproc) * {$cpuPercentage} + 99) / 100 ))\"; else printf 'gzip -3'; fi";
}
}