setName('backup:target:append-only') ->setDescription('Make a location append-only (NG Backup never deletes there) or normal again') ->addArgument('target', InputArgument::REQUIRED, 'Location name or id') ->addArgument('state', InputArgument::REQUIRED, 'on or off') ->setHelp("Append-only protects backups if this server is compromised: combine it with credentials\nwithout delete rights and a lifecycle rule or object lock on the location itself."); } protected function execute(InputInterface $input, OutputInterface $output): int { $state = strtolower((string)$input->getArgument('state')); if (!in_array($state, ['on', 'off'], true)) { $output->writeln('state must be on or off'); return 1; } $t = $this->targets->setAppendOnly($this->targets->get($input->getArgument('target')), $state === 'on'); if ($state === 'off') { $this->alerts->securityEvent('append_only_off', ['target' => $t->getName()]); } $output->writeln($t->getName() . ' is ' . ($t->getAppendOnly() ? 'append-only' : 'normal') . '.'); return 0; } }