Adds a cleanup configuration to the given backup configuration.

@param \phpbu\App\Configuration\Backup $backup
@param array                           $conf
167280
protected function addCleanupIfConfigured(Configuration\Backup $backup, array $conf)
    {
        if (isset($conf['cleanup'])) {
            $backup->setCleanup(
                new Configuration\Backup\Cleanup(
                    $conf['cleanup']['type'],
                    false,
                    $conf['cleanup']['options']
                )
            );
        }
    }
1304480
protected function backupFieldsForCount()
    {
        foreach (['orders', 'limit', 'offset', 'columns'] as $field) {
            $this->backups[$field] = $this->{$field};

            $this->{$field} = null;
        }

        foreach (['order', 'select'] as $key) {
            $this->bindingBackups[$key] = $this->bindings[$key];

            $this->bindings[$key] = [];
        }
    }
151913
def cleanup(config=None, path=None):
    """"""
    if config is None:
        config = parse()
    if path is None:
        path = os.getcwd()
    root = config.get('root', 'path')
    root = os.path.join(path, root)
    if sys.path[0] == root:
        sys.path.remove(root)
921674
protected function backupFieldsForCount()
    {
        foreach (array('orders', 'limit', 'offset') as $field) {
            $this->backups[$field] = $this->{$field};

            $this->{$field} = null;
        }

    }
1346146
static void cleanUpAndCheckBackup(Configuration conf, File origin) throws IOException {
    // get all backups
    String[] backups = getBackups(origin);
    File root = origin.getParentFile();
    
    // maximum total number of backups
    int copiesToKeep = conf.getInt(NN_IMAGE_COPIES_TOKEEP,
        NN_IMAGE_COPIES_TOKEEP_DEFAULT);

    // days to keep, if set to 0 than keep only last backup
    int daysToKeep = conf.getInt(NN_IMAGE_DAYS_TOKEEP,
        NN_IMAGE_DAYS_TOKEEP_DEFAULT);
    
    if (copiesToKeep == 0 && daysToKeep == 0) {
      // Do not delete anything in this case
      // every startup will create extra checkpoint
      return;
    }
    
    // cleanup copies older than daysToKeep
    deleteOldBackups(root, backups, daysToKeep, copiesToKeep);
    
    // check remaining backups
    backups = getBackups(origin);
    if (backups.length >= copiesToKeep) {
      throw new IOException("Exceeded maximum number of standby backups of "
          + origin + " under " + origin.getParentFile() + " max: " + copiesToKeep);
    }
  }
188818
def done(self, conf, rm_conf):
        
        if self.config.obfuscate:
            cleaner = SOSCleaner(quiet=True)
            clean_opts = CleanOptions(
                self.config, self.archive.tmp_dir, rm_conf, self.hostname_path)
            fresh = cleaner.clean_report(clean_opts, self.archive.archive_dir)
            if clean_opts.keyword_file is not None:
                os.remove(clean_opts.keyword_file.name)
                logger.warn("WARNING: Skipping keywords found in remove.conf")
            return fresh[0]
        return self.archive.create_tar_file()
485863
public function handleEnd($conn) {
        try {
            $this->app->onClose($conn->decor);
        } catch (\Exception $e) {
            $this->handleError($e, $conn);
        }

        unset($conn->decor);
    }
425670
function setConfig(newConf, isClearPrevious) {
    checkIsObject(newConf);
    config = isClearPrevious ? Immutable.fromJS(newConf) : config.merge(newConf);
}
434243
public function setConfig(array $config, $file = null)
    {
        $file = !empty($file) ? $file : $this->fileCache;
        if (file_exists($file)) {
            unlink($file);
        }
        (new PhpArray())
                ->setUseBracketArraySyntax(true)
                ->toFile($file, $config);
    }
831799
protected function saveConfig(array $config, $file)
    {
        $file = $this->vendorDir . '/' . $file;
        if (!file_exists(dirname($file))) {
            mkdir(dirname($file), 0777, true);
        }
        $array = var_export($config, true);
        file_put_contents($file, "<?php\n\nreturn $array;\n");
        $this->opcacheInvalidate($file);
    }
248131
protected function createBackupFile($original, $backup)
    {
        $isOk = !file_exists($original) || rename($original, $backup);

        return $isOk;
    }
1075820
public function onBackupFinished(BackupEvent $event)
    {
        $database = $event->getDatabase();
        $database->set('finished', (new \DateTime())->format(\DateTime::RFC3339));
        $database->set('state', $event->getStatus());

        if (BackupStatus::STATE_FAILED === $event->getStatus()) {
            $database->set('exception', $this->serializeException($event->getException()));
        }
    }
124970
public function flushConfig($key)
    {
        if (null !== $this->cache) {
            if (isset($this->config[$key]) && array_key_exists('cacheKey', $this->config[$key])) {
                $cacheKey = $this->config[$key]['cacheKey'];
            } else {
                $cacheKey = $this->getCacheKeyForFile($this->getFileNameForKey($key));
            }

            $this->app[$this->cache]->delete($cacheKey);
        }

        unset($this->config[$key]);
    }
1207698
public function addConfig(array $conf = array())
    {
        $appConfig =& $this->config;

        // Iterate through new top-level keys
        foreach ($conf as $key => $value) {

            // If doesnt exist yet, create it
            if (!isset($appConfig[$key])) {
                $appConfig[$key] = $value;
                continue;
            }

            // If it exists, and is already an array
            if (is_array($appConfig[$key])) {
                $mergedArray = array_merge_recursive($appConfig[$key], $value);
                $appConfig[$key] = $mergedArray;
                continue;
            }

            //@TODO check for iterators?

            // Just set the value already!
            $appConfig[$key] = $value;
        }
    }
1216475
protected function mergeModuleConfig(string $key, array $config)
    {
        if (!empty($config)) {
            $current = $this->app['config']->get($key);
            if (is_array($current)) {
                $this->app['config']->set($key, array_merge($current, $config));
            } else {
                $this->app['config']->set($key, $config);
            }
        }
    }
42608
function onImageFileSent(file, config) {
    if (config.cleanupRuntime) {
        fs.unlink(file, () => logger.debug('Deleted file: %s', file));
    }
}
1263474
public function translateBackup($type, array $conf)
    {
        /** @var \phpbu\App\Configuration\Backup $backup */
        $backup = $this->{$this->types[$type]}($conf);
        $backup->setTarget($this->translateTarget($conf['target']));

        $this->addChecksIfConfigured($backup, $conf);
        $this->addSyncIfConfigured($backup, $conf);
        $this->addCleanupIfConfigured($backup, $conf);
        $this->addCryptIfConfigured($backup, $conf);

        return $backup;
    }