Package org.opends.server.backup
Class BackupManager
java.lang.Object
org.opends.server.backup.BackupManager
This is the primary class for managing backups, it works on top of an arbitrary backup storage and allows to backup
and restore backupable entities as well as listing and verifying backups. A backup manager does not cache the backup
storage content. Multiple backup managers from any DS instance in the topology, working on top of the same backup
storage may concurrently call any of the backup manager methods.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Filters the available backups using the provided criteria.static interface
Iterator able to return a count of progress and the total number of items to be processed.static final class
Counted iterator returning elements from a list. -
Constructor Summary
ConstructorDescriptionBackupManager
(BackupFileManager backupFileManager, String serverId) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreateBackup
(Backupable backupable, Cancellable cancellable) Backs up a backend to the underlying backup storage.listBackups
(BackupManager.BackupFilter backupFilter, Collection<LocalizableMessage> errors) Lists all the backups without verifying their integrity.static BackupManager
newBackupManager
(BackupStorage backupStorage, ServerContext serverContext) Creates a new backup manager backed by the provided backup storage.void
purgeBackups
(Set<BackupId> backupsToDelete, Cancellable cancellable) Purge a set of backups.void
restoreBackup
(Backup backup, Backupable backupable, Cancellable cancellable) Restores a backend from the underlying backup storage.void
verifyBackups
(Collection<Backup> backups, Cancellable cancellable) Verifies the integrity of the provided backups and mark them asBackup.verified()
orBackup.hasErrors()
.
-
Constructor Details
-
BackupManager
Constructor.- Parameters:
backupFileManager
- the backup file managerserverId
- the server id
-
-
Method Details
-
newBackupManager
public static BackupManager newBackupManager(BackupStorage backupStorage, ServerContext serverContext) throws com.forgerock.opendj.cli.ClientException Creates a new backup manager backed by the provided backup storage.- Parameters:
backupStorage
- The backup storage where to read and write backups.serverContext
- The server context.- Returns:
- A backup manager backed by the provided backup storage.
- Throws:
com.forgerock.opendj.cli.ClientException
- If there is an error when trying to obtain the server ID.
-
createBackup
public Backup createBackup(Backupable backupable, Cancellable cancellable) throws BackupException, LdapException Backs up a backend to the underlying backup storage.- Parameters:
backupable
- The backend to be backed up.cancellable
- A way to interrupt the backup operation.- Returns:
- The backup that was just created.
- Throws:
BackupException
- If there is a problem when storing files to the underlying backup storage.LdapException
- If there is a problem when reading backend data.
-
restoreBackup
public void restoreBackup(Backup backup, Backupable backupable, Cancellable cancellable) throws BackupException, InitializationException Restores a backend from the underlying backup storage. If the backend directory does not exist, it will be created in order to easily initialize a backend from a backup. Before restoring, this method verifies that the underlying backup storage contains all the backup files needed for a complete restore. After this verification, all the current backend files are removed. Backup file integrity is only verified each time a file is completely transferred, if one backup file corruption is detected or if there is an IO error, restore will stop and all the backend files will be removed, leaving the backend empty.- Parameters:
backup
- The backup to be restored.backupable
- The backend to be restored.cancellable
- A way to interrupt the restore operation.- Throws:
BackupException
- If backup files are missing, corrupted or their integrity cannot be verified.InitializationException
- If there was a problem when trying to replace the current backend files with the backup files.
-
verifyBackups
Verifies the integrity of the provided backups and mark them asBackup.verified()
orBackup.hasErrors()
. The errors can be retrieved withBackup.getErrors()
. The integrity of each backend file will be verified only once even if files are shared across the provided backups.- Parameters:
backups
- The backups to be verified.cancellable
- A way to interrupt the verification.
-
listBackups
public Collection<Backup> listBackups(BackupManager.BackupFilter backupFilter, Collection<LocalizableMessage> errors) throws BackupException Lists all the backups without verifying their integrity. The returned collection has no specific order. This method does best effort to list all the backups, if there is an error when trying to read a backup, the error message is added to the provided error collection and the method does not throw an exception.- Parameters:
backupFilter
- Filters the backups that wil be returned.errors
- A collection where each error message encountered when trying to read a backup will be added.- Returns:
- A collection containing all the backups.
- Throws:
BackupException
- If it is not possible to read the backup storage content.
-
purgeBackups
public void purgeBackups(Set<BackupId> backupsToDelete, Cancellable cancellable) throws BackupException Purge a set of backups. The purge operation aims to delete all the files related to the given backup. If a purge operation has been interrupted, calling this method again will purge any remaining dangling data files.- Parameters:
backupsToDelete
- The backupIds of the backups to purge.cancellable
- A way to interrupt the restore operation.- Throws:
BackupException
- whenever an error occurred while purging the backup.
-