Class ConfluenceBackupRestoreManager
- java.lang.Object
-
- com.atlassian.confluence.impl.backuprestore.ConfluenceBackupRestoreManager
-
- All Implemented Interfaces:
BackupRestoreManager
public class ConfluenceBackupRestoreManager extends Object implements BackupRestoreManager
Responsible for accepting backup/restore operations, checking permissions, managing the queue and cluster-wide locks. Uses BackupRestoreService for the actual backup/restore operations. NOTE: At this moment, this implementation does not support Confluence cluster. So each mode works independently.- Since:
- 7.17.0
-
-
Constructor Summary
Constructors Constructor Description ConfluenceBackupRestoreManager(BackupRestoreJobRunner backupRestoreJobRunner, BackupRestorePermissionsHelper permissionsHelper, BackupRestoreJobDao backupRestoreJobDao, com.atlassian.beehive.ClusterLockService clusterLockService, ConfluenceBackupRestoreJobCanceller confluenceBackupRestoreJobCanceller, com.atlassian.event.api.EventPublisher eventPublisher, BackupRestoreFilesystemManager backupRestoreFilesystemManager, ZduManager zduManager, IndependentBackupRestoreJobManager independentBackupRestoreJobManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertUserHasSystemAdminPermissions()
Checks whether the current user can upload a backup file.int
cancelAllJobsFromQueue()
Cancels all queued jobs including jobs in QUEUED state and PROCESSING state.Optional<BackupRestoreJob>
cancelJob(Long jobId)
Cancels the job.Collection<BackupRestoreJob>
findJobs(BackupRestoreJobsSearchFilter backupRestoreJobsSearchFilter)
Returns jobs based on the filter provided.Optional<BackupRestoreJob>
getJob(Long jobId)
Get job by id.BackupRestoreSettings
getSettingsById(long jobId)
Returns job settings.Optional<BackupRestoreJobResult>
getStatisticsById(long jobId)
void
processJobsFromTheQueue()
BackupRestoreJob
startSiteBackup(BackupRestoreSettings siteBackupSettings)
Queues a new site backup job if possible.BackupRestoreJob
startSiteRestore(BackupRestoreSettings siteRestoreSettings)
Queues the new site restore job if possible.BackupRestoreJob
startSpaceBackup(BackupRestoreSettings spaceBackupSettings)
Adds the new space backup job to the queue.BackupRestoreJob
startSpaceRestore(BackupRestoreSettings spaceRestoreSettings)
Adds the new space restore job to the queue.
-
-
-
Constructor Detail
-
ConfluenceBackupRestoreManager
public ConfluenceBackupRestoreManager(BackupRestoreJobRunner backupRestoreJobRunner, BackupRestorePermissionsHelper permissionsHelper, BackupRestoreJobDao backupRestoreJobDao, com.atlassian.beehive.ClusterLockService clusterLockService, ConfluenceBackupRestoreJobCanceller confluenceBackupRestoreJobCanceller, com.atlassian.event.api.EventPublisher eventPublisher, BackupRestoreFilesystemManager backupRestoreFilesystemManager, ZduManager zduManager, IndependentBackupRestoreJobManager independentBackupRestoreJobManager)
-
-
Method Detail
-
startSiteBackup
public BackupRestoreJob startSiteBackup(BackupRestoreSettings siteBackupSettings) throws NotPermittedException
Queues a new site backup job if possible. Throws an exception if the operation is not permitted. The user has to be a sysadmin to perform this operation.- Specified by:
startSiteBackup
in interfaceBackupRestoreManager
- Parameters:
siteBackupSettings
- site backup settings- Throws:
NotPermittedException
-
startSiteRestore
public BackupRestoreJob startSiteRestore(BackupRestoreSettings siteRestoreSettings) throws NotPermittedException
Queues the new site restore job if possible. It cancels all other jobs and starts the restore just after. Throws an exception if the operation is not permitted.- Specified by:
startSiteRestore
in interfaceBackupRestoreManager
- Parameters:
siteRestoreSettings
- site restore settings- Throws:
NotPermittedException
-
startSpaceRestore
public BackupRestoreJob startSpaceRestore(BackupRestoreSettings spaceRestoreSettings) throws NotPermittedException
Adds the new space restore job to the queue. Throws an exception if the operation is not permitted. The user has to the a sysadmin to perform this operation.- Specified by:
startSpaceRestore
in interfaceBackupRestoreManager
- Parameters:
spaceRestoreSettings
- space restore settings- Throws:
NotPermittedException
-
getJob
public Optional<BackupRestoreJob> getJob(Long jobId) throws NotPermittedException
Get job by id.- Specified by:
getJob
in interfaceBackupRestoreManager
- Throws:
NotPermittedException
-
startSpaceBackup
public BackupRestoreJob startSpaceBackup(BackupRestoreSettings spaceBackupSettings) throws NotPermittedException, TheSameSpaceBackupRestoreJobAlreadyInProgressException, IllegalArgumentException
Adds the new space backup job to the queue. Throws an exception if the operation is not permitted. Support either single-space backup ot multi-space backups (depends on how many space ids are provided).- Specified by:
startSpaceBackup
in interfaceBackupRestoreManager
- Parameters:
spaceBackupSettings
- space backup settings- Throws:
NotPermittedException
TheSameSpaceBackupRestoreJobAlreadyInProgressException
IllegalArgumentException
-
processJobsFromTheQueue
public void processJobsFromTheQueue()
-
cancelJob
public Optional<BackupRestoreJob> cancelJob(Long jobId) throws NotPermittedException
Cancels the job. If the job is already cancelled or failed, the method will do nothing. Throws an exception if the operation is not permitted.- Specified by:
cancelJob
in interfaceBackupRestoreManager
- Parameters:
jobId
- jobId- Returns:
- the job
- Throws:
NotPermittedException
-
cancelAllJobsFromQueue
public int cancelAllJobsFromQueue() throws NotPermittedException
Description copied from interface:BackupRestoreManager
Cancels all queued jobs including jobs in QUEUED state and PROCESSING state.- Specified by:
cancelAllJobsFromQueue
in interfaceBackupRestoreManager
- Returns:
- number of cancelled jobs.
- Throws:
NotPermittedException
-
findJobs
public Collection<BackupRestoreJob> findJobs(BackupRestoreJobsSearchFilter backupRestoreJobsSearchFilter)
Returns jobs based on the filter provided. Permissions are based on the user SysAdmins can return all, Users can return only jobs that they have space export permissions for- Specified by:
findJobs
in interfaceBackupRestoreManager
- Parameters:
backupRestoreJobsSearchFilter
- properties to filter jobs by- Returns:
- List of BackupRestoreJobs
-
assertUserHasSystemAdminPermissions
public void assertUserHasSystemAdminPermissions() throws NotPermittedException
Description copied from interface:BackupRestoreManager
Checks whether the current user can upload a backup file. Throws a PermissionException if the user does not have permission.- Specified by:
assertUserHasSystemAdminPermissions
in interfaceBackupRestoreManager
- Throws:
NotPermittedException
-
getSettingsById
public BackupRestoreSettings getSettingsById(long jobId)
Description copied from interface:BackupRestoreManager
Returns job settings.- Specified by:
getSettingsById
in interfaceBackupRestoreManager
- Parameters:
jobId
- job id- Returns:
- settings
-
getStatisticsById
public Optional<BackupRestoreJobResult> getStatisticsById(long jobId)
- Specified by:
getStatisticsById
in interfaceBackupRestoreManager
- Parameters:
jobId
-- Returns:
- job's statistics or empty statistics record if no statistics exist
-
-