Skip to content

Commit

Permalink
Merge pull request #33 from p-bizouard/restic-stats-tag
Browse files Browse the repository at this point in the history
restic(check): 💚 Add restic tag to filter specific snapshots on repository (useful for Velero)
  • Loading branch information
p-bizouard authored Mar 6, 2024
2 parents 68e8ecf + fda835c commit abc2d1c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Service/BackupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit abc2d1c

Please sign in to comment.