From fda835c10d09edc001433754c09d80ccbec4c99d Mon Sep 17 00:00:00 2001 From: Paul Bizouard Date: Wed, 6 Mar 2024 23:14:03 +0100 Subject: [PATCH] =?UTF-8?q?restic(check):=20=F0=9F=92=9A=20Add=20restic=20?= =?UTF-8?q?tag=20to=20filter=20specific=20snapshots=20on=20repository=20(u?= =?UTF-8?q?seful=20for=20Velero)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Service/BackupService.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Service/BackupService.php b/src/Service/BackupService.php index d5fdb31..0c4ed12 100644 --- a/src/Service/BackupService.php +++ b/src/Service/BackupService.php @@ -1008,7 +1008,6 @@ public function healhCheckBackup(Backup $backup, bool $tryRepair = true): void ]; $this->log($backup, Log::LOG_INFO, sprintf('Run `%s` with %s', $command, nl2br($this->logParameters($parameters)))); - $process = Process::fromShellCommandline($command, null, $parameters); $process = Process::fromShellCommandline($command, null, $env + $parameters); $process->setTimeout(self::RESTIC_CHECK_TIMEOUT); @@ -1051,10 +1050,17 @@ public function healhCheckBackup(Backup $backup, bool $tryRepair = true): void ]; foreach ($sizes as $resticCommandSuffix => $backupAttribute) { - $command = sprintf('restic stats --json %s', $resticCommandSuffix); + $command = sprintf('restic stats --json %s %s', $resticCommandSuffix, + $backup->getBackupConfiguration()->getResticCheckTags() ? '--tag "${RESTIC_CHECK_TAG}"' : '' + ); + + $parameters = [ + 'RESTIC_CHECK_TAG' => $backup->getBackupConfiguration()->getResticCheckTags(), + ]; + + $this->log($backup, Log::LOG_INFO, sprintf('Run `%s` with %s', $command, nl2br($this->logParameters($parameters)))); - $this->log($backup, Log::LOG_INFO, sprintf('Run `%s`', $command)); - $process = Process::fromShellCommandline($command, null, $env); + $process = Process::fromShellCommandline($command, null, $env + $parameters); $process->setTimeout(self::RESTIC_CHECK_TIMEOUT); $process->run();