setName('backup:list') ->setDescription('List the snapshots (restore points) on a location') ->addArgument('target', InputArgument::OPTIONAL, 'Location name or id (default: all)'); } protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('target'); $targets = $name === null ? $this->targets->list() : [$this->targets->get($name)]; $zone = $this->schedule->get()['timezone']; $rows = []; foreach ($targets as $t) { foreach ($this->snapshots->findForTarget($t->getId()) as $s) { $rows[] = [$t->getName(), $s->getSnapshotId(), Format::time($s->getCreatedAt(), $zone), $s->getKind(), $s->getFiles(), sprintf('%.1f GiB', ($s->getBytes() ?? 0) / 1073741824), $s->getLabel() ?? '']; } } if ($rows === []) { $output->writeln('No snapshots yet (occ backup:run).'); return 0; } (new Table($output))->setHeaders(['location', 'snapshot', "date ($zone)", 'kind', 'files', 'size', 'label'])->setRows($rows)->render(); return 0; } }