Reason
When somebody wants to backup either the JIRA or Confluence onDemand databases.
Context
Atlassian onDemand does not currently have any features for automating a backup of either JIRA or Confluence. To get around this we can trigger a backup from Atlassian and then automatically download the resulting file to a location of our choosing. We can take this a step further by automating this processes with a cron job on Mac or Unix, or by using Windows Task Scheduler.
Disclaimer
These scripts were based on one given for Jira by Marlon Aguiar of Atlassian, the original can be found here. Some minor modifications were made and a separate script for Confluence was created from the resulting code.
Guide
Jira
- Create a bash script with the following code, filling in your Atlassian username and password. Save it as “JiraBackup.sh”.
- Make the script executable with
chmod +x JiraBackup.sh
- Execute the script with
./JiraBackup.sh
Confluence
- Create a bash script with the following code, filling in your Atlassian username and password. Save it as “ConfluenceBackup.sh”.
- Make the script executable with
chmod +x ConfluenceBackup.sh
- Execute the script with
./ConfluenceBackup.sh
The scripts will trigger a backup and automatically download the resulting file to a specially created Backups folder located in the same directory where the script is.
Automating
Windows
Windows users are able to automatically trigger the script by using Windows Task Scheduler. It is very easy to set up and more information can be found here http://technet.microsoft.com/en-us/library/bb726974.aspx
Mac/Unix
The easiest way to automatically trigger this at regular intervals is to set up a cron job.
- In the terminal, open your crontab
crontab -e
- Press i to enter vim’s insert mode
- Enter your jobs. The following example will trigger the jobs every 3 days
00 00 3 * *
/BackupJira.sh 00 00 3 * *
/ConfluenceBackup.sh - Press [ESC] to exit insert mode
- Type ZZ (Must be capitals)
- You can verify the new entries with
crontab -l
- There is a Ruby gem available for accomplishing both of these tasks available at https://github.com/kreuzwerker/aodb
- The backups are available for direct access at https://company.atlassian.net/webdav/backupmanager/
- A good primer for Cron is available at http://www.unixgeeks.org/security/newbie/unix/cron-1.html