AWS Application Services

Automate Confluence Backup Using AWS Step Functions

6 min read
Updated June 24, 2025
6,245 characters

The Challenge: SaaS Data Protection

Many organizations rely on SaaS platforms like Atlassian Confluence for critical documentation and collaboration. While these platforms are highly available, relying solely on the vendor for data protection is risky. Accidental data deletion, corruption, or account-level issues can occur. Therefore, performing regular, automated backups to a location you control (like Amazon S3) is a crucial part of a robust data protection strategy.

The Solution: A Serverless Orchestration Workflow

This guide outlines a serverless, event-driven architecture on AWS to automate Confluence backups. The solution is built around AWS Step Functions, which orchestrates a series of AWS Lambda functions and other services to create a resilient, cost-effective, and low-maintenance backup process.


The Architecture

The architecture uses a combination of managed AWS services to create a workflow that is triggered on a schedule, interacts with the Confluence API, and handles the asynchronous nature of a backup task.

Core Components:

  • Amazon EventBridge Scheduler: Kicks off the entire process on a recurring schedule (e.g., weekly at 1 AM).

  • AWS Step Functions: The core orchestrator. It manages the state of the workflow, handles errors, and ensures the steps are executed in the correct order.

  • AWS Lambda: Provides the serverless compute logic to interact with the Confluence REST API.

  • Amazon S3: The secure, durable, and cost-effective destination for storing the backup artifacts.

  • Amazon SNS: Used to send notifications about the success or failure of the backup process.

A Simple Diagram of the Flow:

EventBridge Scheduler -> Step Functions State Machine -> [Lambda -> Lambda -> Lambda] -> S3 Bucket

|

+-----------------> SNS (Notifications)


How It Works: The State Machine Workflow

The power of this pattern lies in how Step Functions manages a long-running, asynchronous task. Generating a backup in Confluence is not instant; it can take several minutes to hours. The state machine handles this waiting period gracefully.

Step 1: Initiate the Backup

  • The workflow starts with a Task state that invokes a Lambda function (e.g., initiateBackupFunction).

  • This function makes an API call to the Confluence REST API to request a new backup.

  • Confluence acknowledges the request and begins generating the backup file in the background. It does not return the backup file immediately.

Step 2: Wait for Completion (The Callback Pattern)

  • This is the most critical part of the pattern. The Step Functions workflow enters a Task state configured with the .waitForTaskToken integration pattern.

  • When this state starts, Step Functions generates a unique taskToken and then pauses the workflow indefinitely.

  • The initiateBackupFunction from Step 1 is responsible for passing this taskToken to a component that can monitor the backup's progress.

Step 3: Check Status and Resume

There are two common ways to handle the "wait" period:

  • Polling Approach (Simpler): A second Lambda function (checkStatusFunction) is triggered by another EventBridge rule every few minutes. It polls the Confluence API, checking the status of the backup job. When it sees the job is complete, it calls the Step Functions API with SendTaskSuccess and the taskToken, which resumes the workflow.

  • Webhook Approach (More Efficient): If the SaaS tool supports it, you configure a webhook in Confluence to send a "backup complete" event to an Amazon API Gateway endpoint. The endpoint triggers a Lambda function that calls SendTaskSuccess with the taskToken, instantly resuming the workflow.

Step 4: Download and Store the Backup

  • Once the workflow resumes, it transitions to a new Task state that invokes a final Lambda function (e.g., storeBackupFunction).

  • This function gets the download URL for the completed backup file from the resumed workflow's input.

  • It downloads the file and streams it directly into a designated Amazon S3 bucket for long-term, secure storage.

Step 5: Handle Success or Failure

  • The state machine is configured with Catch blocks for error handling.

  • If any step fails (e.g., the API call fails, the backup job fails in Confluence), the workflow transitions to a failure state.

  • Both success and failure states can be configured to publish a message to an SNS topic, which can then send an email or a Slack message to notify administrators of the backup result.


Key AWS Services Used

  • AWS Step Functions: Provides the central orchestration, state management, and error handling. Its ability to wait for a task token is key to managing the asynchronous backup process.

  • AWS Lambda: Runs the custom code needed to interact with the Confluence API without requiring you to manage servers.

  • Amazon EventBridge Scheduler: A reliable, serverless cron service to trigger the state machine on a consistent schedule.

  • Amazon S3: Offers a highly durable and low-cost solution for storing backup files. Lifecycle policies can be used to automatically move older backups to cheaper storage tiers (like S3 Glacier).

  • Amazon SNS: A simple and effective pub/sub service for fanning out notifications upon completion or failure of the workflow.


Benefits of this Approach

  • Serverless and Low Cost: You only pay for the resources you consume during the workflow execution. There are no idle servers to manage or pay for.

  • Resilient and Fault-Tolerant: Step Functions' built-in retry mechanisms and error handling allow the workflow to gracefully handle transient API errors.

  • Low Maintenance: Once deployed, the entire process is automated. AWS manages the underlying infrastructure, scaling, and availability of all the services used.

  • Reusable Pattern: This architecture is not limited to Confluence. It can be adapted to back up any SaaS platform that provides an asynchronous API for data exports.