Interface Backupable
-
- All Known Implementing Classes:
ConfigurationBackend,JEStorage,PDBStorage,SchemaBackend,TaskBackend
public interface BackupableRepresents 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
ThegetDirectory()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: iftrue, it is a direct restore, otherwise it is an indirect restore.Actions taken before and after the restore should be handled in the
beforeRestore()andafterRestore(Path, Path)methods.- See Also:
BackupManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidafterRestore(Path restoreDirectory, Path saveDirectory)Called after the restore operation has finished successfully.PathbeforeRestore()Called before the restore operation begins.FilegetDirectory()Returns the directory which acts as the root of all files to backup and restore.ListIterator<Path>getFilesToBackup()Returns the files to backup.booleanisDirectRestore()Indicates if restore is done directly in the restore directory.
-
-
-
Method Detail
-
getFilesToBackup
ListIterator<Path> getFilesToBackup() throws DirectoryException
Returns the files to backup.- Returns:
- an iterator of files to backup, which may be empty but never
null - Throws:
DirectoryException- If an error occurs.
-
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:
trueif restore is done directly in the restore directory provided bygetDirectory()method, orfalseif 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
nullif 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 nevernull.saveDirectory- The directory in which current files have been saved. It may benullifbeforeRestore()returnednull.- Throws:
DirectoryException- If an error occurs.
-
-