Skip to content

Commit

Permalink
restic(check): 💚 Add restic tag to filter specific snapshots on repos…
Browse files Browse the repository at this point in the history
…itory (useful for Velero)
  • Loading branch information
p-bizouard committed Mar 6, 2024
1 parent 68e8ecf commit fda835c
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 fda835c

Please sign in to comment.