Here I'll introduce a way to automate site backups of Jira Cloud and Confluence Cloud with Jira Automation.
(0) Why site-backup is important
Atlassian doesn't officially provide data rollback based on customer requests. So it's essential to take site backup regularly. For example, the backup will help you restore data when any of the site data is lost by a user's interaction. Refer to the following part in Data storage FAQ for more details:
Atlassian cloud sites don't support the use of backup data to roll back changes.
First, let me clarify what is covered by this article. The approach introduced here is only good as a temporary workaround as there are some constraints, such as:
- Disclaimer: This approach is not officially supported and is currently maintained by the community. Consider voting for CLOUD-6498 to show your interest in official support.
- Prerequisite:
You need to subscribe to at least one Jira family product; meaning it's unable to follow this instruction if you only with Confluence subscription as we'll utilize Jira Automation feature which is only available for Jira. Now Confluence is going to have Automation as well.
- Importantly, in this approach, we skip downloading the created site backups to any local machine simply because it's better than nothing. It is recommended for sure to download site-backups if you can. To do so, use the bash scripts listed below:
(1) Preparation
First things first, you always need to have credentials when you do something important:
- Issue an API token of the site-admins account at https://id.atlassian.com/manage/api-tokens
- Encode your credentials "$EMAIL_ADDRESS:$API_TOKEN" with base64 as (1-2) Example below. Or go with any online tool like Base64 Encode. Make sure not to include a line break at the end.
(1-2) Example - How to encode your API token
$ echo -n "site-admin@example.com:123e4567-e89b-12d3-a456-426614174000" | base64
c2l0ZS1hZG1pbkBleGFtcGxlLmNvbToxMjNlNDU2Ny1lODliLTEyZDMtYTQ1Ni00MjY2MTQxNzQw
MDA=
Besides, for those using IP Allowlisting, include the egress IP ranges introduced at IP addresses and domains for Atlassian cloud products #Outgoing Connections.
(2) Create a rule for Confluence site-backup
Although you can start with either Jira or Confluence, we'll look into how to configure a rule for Confluence here for convenience.
- Set up the schedule
- Add the content of (2-1) below to Cron expression
- Select "simply run the conditions and actions without providing issues" for When rule executes
- Add an action - Send web requests
- Webhook URL: {{baseUrl}}/wiki/rest/obm/1.0/runbackup
- Headers:
- Authorization: Basic <The output we got from (1-2)>
- Webhook body: refer to (2-2)
- Add another action - Log action
- To be able to keep track of what we got with the webhook request, specify {{webhookResponse}} in Log message
- Name the rule "Site backup - Confluence Cloud" and save the setting
- Do a test run with [Run rule] button
- The log then will be available in the Audit log
- Check the download link
(2-1) Cron expression
Each backup should be performed after a 48-hour interval at least. We here are going to schedule the execution twice a week on Monday and Thursday. Also, make sure to avoid maintenance windows for your site. For example, suppose your company sits in EST, specify 9 am in UTC:
0 0 9 ? * 1,4
(2-2) Webhook body
{"cbAttachments":"true" }
(3) Create a rule for Jira site backup
I'll put the diff in settings as it's almost the same with Confluence.
- Schedule - same
- Action - Send web request
- Webhook URL: {{baseUrl}}/rest/backup/1/export/runbackup
- Webhook body: refer to (3-1)
- Remaining procedures - same
(3-1) Cron expression
Same here, on Monday and Thursday at 9 am in UTC:
0 0 9 ? * 1,4
(3-2) Webhook body
{"cbAttachments":"true", "exportToCloud":"true"}
(4) Constraints
Other than noted above, there are several points you should be aware of:
- Jira has an upper bound on rule executions per subscription plan. That means you will not get a backup if exceed the limit. So consider upgrading to Premium, especially if you already have a respectable number of existing global automation rules.
- The backup link will be available for 14 days for Jira and 7 days for Confluence. The link then will be replaced by the subsequent one. That means you will only be able to retrieve the backup file until the next backup ends. So make sure to download the backup file as soon as you find any data loss; otherwise, the backup link will be replaced with the one taken after the data loss.
71 comments