Class BackupManager


  • public class BackupManager
    extends Object
    A backup manager for any entity that is backupable (backend, storage).
    See Also:
    Backupable
    • Constructor Detail

      • BackupManager

        public BackupManager​(String backendID)
        Construct a backup manager for a backend.
        Parameters:
        backendID - The ID of the backend instance for which a backup manager is required.
    • Method Detail

      • createBackup

        public void createBackup​(Backupable backupable,
                                 BackupConfig backupConfig)
                          throws DirectoryException
        Creates a backup of the provided backupable entity.

        The backup is stored in a single zip file in the backup directory.

        If the backup is incremental, then the first entry in the zip is a text file containing a list of all the log files that are unchanged since the previous backup. The remaining zip entries are the log files themselves, which, for an incremental, only include those files that have changed.

        Parameters:
        backupable - The underlying entity (storage, backend) to be backed up.
        backupConfig - The configuration to use when performing the backup.
        Throws:
        DirectoryException - If a Directory Server error occurs.
      • restoreBackup

        public void restoreBackup​(Backupable backupable,
                                  RestoreConfig restoreConfig)
                           throws DirectoryException
        Restores a backupable entity from its backup, or verify the backup.
        Parameters:
        backupable - The underlying entity (storage, backend) to be backed up.
        restoreConfig - The configuration to use when performing the restore.
        Throws:
        DirectoryException - If a Directory Server error occurs.
      • removeBackup

        public void removeBackup​(BackupDirectory backupDir,
                                 String backupID)
                          throws DirectoryException
        Removes the specified backup if it is possible to do so.
        Parameters:
        backupDir - The backup directory structure with which the specified backup is associated.
        backupID - The backup ID for the backup to be removed.
        Throws:
        DirectoryException - If it is not possible to remove the specified backup for some reason (e.g., no such backup exists or there are other backups that are dependent upon it).
      • getFiles

        public static List<Path> getFiles​(File directory,
                                          FileFilter filter,
                                          String identifier)
                                   throws DirectoryException
        Helper method to build a list of files to backup, in the simple case where all files are located under the provided directory.
        Parameters:
        directory - The directory containing files to backup.
        filter - The filter to select files to backup.
        identifier - Identifier of the backed-up entity
        Returns:
        the files to backup, which may be empty but never null
        Throws:
        DirectoryException - if an error occurs.
      • saveCurrentFilesToDirectory

        public static Path saveCurrentFilesToDirectory​(Backupable backupable,
                                                       String identifier)
                                                throws DirectoryException
        Helper method to save all current files of the provided backupable entity, using default behavior.
        Parameters:
        backupable - The entity to backup.
        identifier - Identifier of the backup
        Returns:
        the directory where all files are saved.
        Throws:
        DirectoryException - If a problem occurs.
      • saveFilesToDirectory

        public static Path saveFilesToDirectory​(Path rootDirectory,
                                                ListIterator<Path> files,
                                                String targetBasePath,
                                                String identifier)
                                         throws DirectoryException
        Helper method to move all provided files in a target directory created from provided target base path, keeping relative path information relative to root directory.
        Parameters:
        rootDirectory - A directory which is an ancestor of all provided files.
        files - The files to move.
        targetBasePath - Base path of the target directory. Actual directory is built by adding ".save" and a number, always ensuring that the directory is new.
        identifier - Identifier of the backup
        Returns:
        the actual directory where all files are saved.
        Throws:
        DirectoryException - If a problem occurs.