Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

🎁 Get 20% Off - Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

Automate Confluence Backup Using AWS Step Functions

Home » AWS » Automate Confluence Backup Using AWS Step Functions

Automate Confluence Backup Using AWS Step Functions

Last updated on April 27, 2023

Introduction

In this article, I’m gonna show you how you can create an automated Confluence backup in Atlassian using an AWS serverless solution. The motivation behind this article stems from a recent task I was working on a couple of weeks ago. My goal was to run a scheduled backup of Confluence data and export it to Amazon S3. Since Confluence backups are deleted 14 days after creation, it’s a good idea to have additional copies in a different location in case something goes wrong with your Confluence instance or if you need to restore data from a point in time. I couldn’t find any cloud-based references online that resembled my intended approach, so I thought it would be worthwhile to share this solution in case it proves useful to someone else.

Why Step Functions?

Initially, I thought of writing the code in a single Lambda function. However, at the time of writing, Lambda functions can only run for a maximum of 15 minutes. Since creating backups can take a while, this limitation could potentially result in failure. To circumvent this issue, I broke up the logic into separate tasks using AWS Step Functions. A workflow in Step Functions can execute for up to one year, allowing us to manage long-running processes like taking backups.

Solution Overview

Automate Confluence Backup Using AWS Step Functions

The solution consists of 3 main components (2 Lambda functions and 1 CodeBuild build project) — all orchestrated by Step Functions.

  1. StartBackup – handles the logic for initiating the backup.
  2. GetBackupProgress – handles the logic for getting the backup progress.
  3. MoveBackupToS3 – downloads the backup to a CodeBuild environment and moves it to an S3 bucket. I opted to use CodeBuild over a Lambda function for long-term purposes. As the backup size grows over time, there is a risk that the Lambda function may eventually fail due to its execution timeout limit. By using CodeBuild, which has a longer maximum runtime, we can avoid this potential issue and ensure the reliability of the solution in the long run.

Steps

Creating an API token in your Atlassian account

  1. Go to https://id.atlassian.com/manage-profile/security/api-tokens.
  2. Click the Create API token button.
  3. On the dialog that appears, enter a short and descriptive label for your token.
  4. Copy the created token and save it somewhere.
  5. Tutorials dojo strip

Creating AWS Systems Manager Agent (SSM) Parameters

  1. Create three parameters in AWS SSM for your Confluence email, token, and site name:

      Example:

  • /confluence/email – enter the email address associated with your Confluence account, which should match the one under which you created the API token
  • /confluence/token – enter the API token that you’ve created
  • /confluence/sitename – enter the name of your Confluence site. For instance, if your site URL is tutorialsdojo.atlassian.net, enter ‘tutorialsdojo‘ (without quotes) as the site name.

Automate Confluence Backup Using AWS Step Functions

Creating an S3 bucket

  1. Create an S3 bucket. This bucket will serve as the destination for your backups.
  2. In the bucket, create a folder named lambda_functions and another one named scripts.

Automate Confluence Backup Using AWS Step Functions

       3.  Upload these zip files in the lambda_functions folder.

       4. Upload this script inside the scripts folder.

 

Deploying the Step Functions workflow

  1. Download the automated_confluence_backup.yaml template from this repository
  2. Go to the AWS CloudFormation Console and deploy the template. Don’t forget to deploy it in the same region where you created the S3 bucket and SSM parameters.
  3. Enter a stack name.
  4. Provide the corresponding values for the parameters.

Automate Confluence Backup Using AWS Step Functions

     5. Click Next > Next > Submit (click the dialog that says “I acknowledge that AWS CloudFormation might create IAM resources.“)

Automate Confluence Backup Using AWS Step Functions

   6. Wait until the stack creation is done.

Verification

  1. Under the Resources tab, go to the newly created Step Functions state machine by clicking on its Physical ID link. 

Automate Confluence Backup Using AWS Step Functions

   2. Click Start Execution

   3. Wait for the backup to be completed. If all goes well, you should see an output similar to the screenshot below:

Automate Confluence Backup Using AWS Step Functions

  4. Confirm if the backup is saved to your S3 bucket. 

Automate Confluence Backup Using AWS Step Functions

 

So what’s next?

You can take this solution further by running the Step Functions workflow on a schedule you prefer through Amazon EventBridge. Feel free to tinker with the workflow and include a notification in case something goes wrong with the backup process. Plus, you don’t want to let super old backups pile up in your S3 bucket. So, think about adding an S3 Lifecycle policy to help tidy up and remove outdated backups.

Conclusion

And that’s about it! Thanks for taking the time to read this article. I hope you gained something valuable. Please don’t hesitate to share it with anyone who might find it helpful too!

 

Get 20% Off – Christmas Big Sale on All Practice Exams, Video Courses, and eBooks!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Carlo Acebedo

Carlo is a cloud engineer and a content creator at Tutorials Dojo. He's also a member of the AWS Community builder and holds 5 AWS Certifications. Carlo specializes in building and automating solutions in the Amazon Web Services Cloud.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?