Class BackupRestoreResource

java.lang.Object
com.atlassian.confluence.plugins.restapi.resources.BackupRestoreResource

public class BackupRestoreResource extends Object
  • Constructor Details

  • Method Details

    • createSpaceBackupJob

      public javax.ws.rs.core.Response createSpaceBackupJob(SpaceBackupSettings settings)
      Creates new space backup job and adds it to the queue.
      Parameters:
      settings - space backup settings
      Returns:
      space backup job details
    • createSiteBackupJob

      public javax.ws.rs.core.Response createSiteBackupJob(SiteBackupSettings settings)
      Starts the new site backup job.
      Parameters:
      settings - site backup settings
      Returns:
      site backup job details
    • createSpaceRestoreJob

      public javax.ws.rs.core.Response createSpaceRestoreJob(SpaceRestoreSettings settings)
      Creates new space restore job and adds it to the queue.
      Parameters:
      settings - space restore settings
      Returns:
      space restore job details
    • createSiteRestoreJob

      public javax.ws.rs.core.Response createSiteRestoreJob(SiteRestoreSettings settings)
      Starts the new site restore job.
      Parameters:
      settings - site restore settings
      Returns:
      site restore job details
    • createSpaceRestoreJobForUploadedBackupFile

      public javax.ws.rs.core.Response createSpaceRestoreJobForUploadedBackupFile(com.atlassian.plugins.rest.common.multipart.FilePart file) throws IOException
      Starts the new space restore job for the uploaded backup file (Zip).

      This resource expects a multipart post. The media-type multipart/form-data is defined in RFC 1867. Most client libraries have classes that make dealing with multipart posts simple. For instance, in Java the Apache HTTP Components library provides a MultiPartEntity that makes it simple to submit a multipart POST.

      In order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: nocheck with the request, otherwise it will be blocked.

      The name of the multipart/form-data parameter that contains attachments must be "file"

      An example to attach the file

      curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.zip" http://myhost/rest/api/backup-restore/restore/space/upload"

      Parameters:
      file - backup file uploaded. Has to be a zip file.
      Returns:
      space restore job details
      Throws:
      IOException
    • createSiteRestoreJobForUploadedBackupFile

      public javax.ws.rs.core.Response createSiteRestoreJobForUploadedBackupFile(com.atlassian.plugins.rest.common.multipart.FilePart file) throws IOException
      Starts the new site restore job for the uploaded backup file (Zip).

      This resource expects a multipart post. The media-type multipart/form-data is defined in RFC 1867. Most client libraries have classes that make dealing with multipart posts simple. For instance, in Java the Apache HTTP Components library provides a MultiPartEntity that makes it simple to submit a multipart POST.

      In order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: nocheck with the request, otherwise it will be blocked.

      The name of the multipart/form-data parameter that contains attachments must be "file"

      An example to attach the file

      curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.zip" http://myhost/rest/api/backup-restore/restore/site/upload"

      Parameters:
      file - backup file uploaded. Has to be a zip file.
      Returns:
      site restore job details
      Throws:
      IOException
    • getJob

      public javax.ws.rs.core.Response getJob(Long jobId)
      Get job by id. The user must be a sysadmin or the owner of the job
      Parameters:
      jobId - id of the backup/restore job
      Returns:
      job details
    • findJobs

      public javax.ws.rs.core.Response findJobs(Integer limit, String fromDate, String toDate, JobScope jobScope, JobOperation jobOperation, List<JobState> jobStates, String spaceKey, String owner)
      Returns jobs based on the filters provided.
      Parameters:
      limit - amount of jobs that should be returned
      fromDate - minimum job creation date. Supported date format is `yyyy-MM-ddTHH:mm:ss.SSSZ`
      toDate - maximum job create date. Supported date format is `yyyy-MM-ddTHH:mm:ss.SSSZ`
      jobScope - scope of the job. Acceptable values: "SPACE" and "SITE"
      jobOperation - job operation. Acceptable values: "BACKUP" and "RESTORE"
      jobStates - list of job states. Acceptable values: "QUEUED", "PROCESSING", "FINISHED", "CANCELLING", "CANCELLED", "FAILED"
      owner - userName of user who had created a job
      Returns:
      List of backup/restore jobs visible to user based on the filter provided and the user's permissions.
    • getFiles

      public javax.ws.rs.core.Response getFiles(JobScope jobScope)
      returns list of information on files in conf-home/restore/(jobScope)
      Parameters:
      jobScope - name of type of restore job (SITE or SPACE or null), if null, all backup files are listed
      Returns:
      List of FileInfo objects, containing fileName, fileCreationTime, fileSize, and jobScope
    • cancelJob

      public javax.ws.rs.core.Response cancelJob(Long jobId)
      Cancels the job. If the job is already cancelled or failed, the method will do nothing.
      Parameters:
      jobId - id of the backup/restore job
      Returns:
      details of cancelled job
    • downloadBackupFile

      public javax.ws.rs.core.Response downloadBackupFile(Long jobId)
      Downloads the backup file for the given job. Requires site admin or space export permissions for all spaces included in the backup job.
      Parameters:
      jobId - id of the backup/restore job
      Returns:
      Complete data stream of the file contents
    • cancelAllQueuedJobs

      public javax.ws.rs.core.Response cancelAllQueuedJobs()
      Cancels all queued jobs. Does not affect jobs that are being processed at the moment.
      Returns:
      number of cancelled jobs.