Interface Backupable

  • All Known Implementing Classes:
    ConfigurationBackend, JEStorage, PDBStorage, SchemaBackend, TaskBackend

    public interface Backupable
    Represents an entity (storage, backend) that can be backed up.

    The files to backup must be located under a root directory given by getDirectory() method. They can be located at any depth level in a sub-directory. For example, file1, file2 and file3 can be returned as files to backup:

     +--- rootDirectory
     |   \--- file1
     |   \--- subDirectory
     |      \--- file2
     |      \--- file3
     
    The getDirectory() method is also used to provide the root directory used for the restore of the backup. The actual restore directory depends on the strategy used for restore, which can be one of these two:
    • Direct restore: the backup is restored directly in the directory provided by getDirectory() method. It is the responsibility of the backupable entity to manage saving of current files before the restore, and to discard them at the end of a successful restore.
    • Indirect restore: the backup is restored in a temporary directory, derived from the directory provided by getDirectory() method (suffixed by "restore-[backupID]"). It is the responsibility of the backupable entity to switch from the temporary directory to the final one.

    The restore strategy is given by isDirectRestore() method: if true, it is a direct restore, otherwise it is an indirect restore.

    Actions taken before and after the restore should be handled in the beforeRestore() and afterRestore(Path, Path) methods.

    See Also:
    BackupManager
    • Method Detail

      • getDirectory

        File getDirectory()
        Returns the directory which acts as the root of all files to backup and restore.
        Returns:
        the root directory
      • isDirectRestore

        boolean isDirectRestore()
        Indicates if restore is done directly in the restore directory.
        Returns:
        true if restore is done directly in the restore directory provided by getDirectory() method, or false if restore is done in a temporary directory.
      • beforeRestore

        Path beforeRestore()
                    throws DirectoryException
        Called before the restore operation begins.

        In case of direct restore, the backupable entity should take any action to save a copy of existing data before restore operation. Saving includes removing the existing data and copying it in a save directory.

        Returns:
        the directory where current files are saved. It may be null if not applicable.
        Throws:
        DirectoryException - If an error occurs.
      • afterRestore

        void afterRestore​(Path restoreDirectory,
                          Path saveDirectory)
                   throws DirectoryException
        Called after the restore operation has finished successfully.

        For direct restore, the backupable entity can safely discard the saved copy. For indirect restore, the backupable entity should switch the restored directory to the final restore directory.

        Parameters:
        restoreDirectory - The directory in which files have actually been restored. It is never null.
        saveDirectory - The directory in which current files have been saved. It may be null if beforeRestore() returned null.
        Throws:
        DirectoryException - If an error occurs.