Class PurgeRunner


  • public final class PurgeRunner
    extends Object
    This class implements the business logic for the dsbackup purge sub-command, whether offline or online.
    • Constructor Detail

      • PurgeRunner

        public PurgeRunner()
    • Method Detail

      • serverContext

        public PurgeRunner serverContext​(ServerContext serverContext)
        Sets the server context.
        Parameters:
        serverContext - The server context.
        Returns:
        A reference to this runner.
      • baseDirectory

        public PurgeRunner baseDirectory​(Path baseDirectory)
        Sets the base directory ie the directory which will be used as the working directory if ever the given backup location is relative local file-system path.
        Parameters:
        baseDirectory - The base directory.
        Returns:
        A reference to this runner.
      • storage

        public PurgeRunner storage​(String backupLocation,
                                   Map<String,​String> properties)
        Register the backup location and the properties for the backup storage.
        Parameters:
        backupLocation - The location of the backup.
        properties - The properties of the backup storage.
        Returns:
        A reference to this runner.
      • interruptWith

        public PurgeRunner interruptWith​(Cancellable cancellable)
        Sets the cancellable for interrupting purge operations.
        Parameters:
        cancellable - The cancellable.
        Returns:
        A reference to this runner.
      • backendNames

        public PurgeRunner backendNames​(Set<String> backendNames)
        Configures the purge runner to purge only backups of the given backend names. This filter can be combined with the other filters (keepCount, olderThan)
        Parameters:
        backendNames - The backend names of the backups to purge.
        Returns:
        A reference to this runner.
      • backupIds

        public PurgeRunner backupIds​(Set<String> backupIds)
                              throws com.forgerock.opendj.cli.ClientException
        Sets a list of backup IDs to purge.
        Parameters:
        backupIds - The list of backup IDs to purge.
        Returns:
        A reference to this runner.
        Throws:
        com.forgerock.opendj.cli.ClientException - if any backup id is invalid
      • keepCount

        public PurgeRunner keepCount​(Integer keepCount)
        Configures the purge process with a keep count value: purge will save only the keepCount latest backups of each backend.
        Parameters:
        keepCount - The number of backups to keep.
        Returns:
        A reference to this runner.
      • olderThan

        public PurgeRunner olderThan​(Duration olderThan,
                                     boolean forceRemove)
        Configures the purge runner with a "remove older than" threshold: purge will delete all the backups older than this threshold. Depending on the value of forceRemove, the latest backup can be kept even if it is older than the specified threshold.
        Parameters:
        olderThan - The threshold to purge the backups.
        forceRemove - Indicates whether to remove all the backups if the threshold applies for all the backups. If set to false, then the latest backup is kept even if it is older than the specified threshold
        Returns:
        A reference to this runner.
      • run

        public void run()
                 throws com.forgerock.opendj.cli.ClientException
        Runs the purge command. Depending on user arguments, this will purge one or more backups. This method continues on errors and will throw an exception if at least one backup purge has failed.
        Throws:
        com.forgerock.opendj.cli.ClientException - If not all backups cannot be purged.