/** * @param Profile $profile * @param string $filename * * @return Backup[] */ private function sendToDestinations(Profile $profile, $filename) { $backups = array(); foreach ($profile->getDestinations() as $destination) { $backup = $destination->push($filename, $this->logger); $size = $backup->getSize(); if (class_exists('\\ByteUnits\\System')) { $size = \ByteUnits\parse($size)->format('B'); } $this->logger->info(sprintf('Backup created for destination "%s" at: "%s" ', $destination->getName(), $backup->getKey()), array('size' => $size, 'created_at' => $backup->getCreatedAt()->format('Y-m-d H:i:s'))); $backups[] = $backup; } return $backups; }
private function listBackups(Destination $destination, OutputInterface $output) { $output->writeln(sprintf('Existing backups for <info>%s</info>:', $destination->getName())); $output->writeln(''); $table = new Table($output); $table->setHeaders(array('Key', 'Size', 'Created At')); $backups = $destination->all(); if (empty($backups)) { $output->writeln(sprintf("<error>No backups for %s</error>\n", $destination->getName())); return; } foreach ($destination->all() as $backup) { $size = $backup->getSize(); if (class_exists('\\ByteUnits\\System')) { $size = \ByteUnits\parse($size)->format('B'); } $table->addRow(array($backup->getKey(), $size, $backup->getCreatedAt()->format('Y-m-d H:i:s'))); } $table->render(); $output->writeln(''); }