Jira AWS Backup & Recovery
This page covers backup an restore using various different methods:
AWS Snapshots
PostgreSQL Database Backups
Jira XML Backups
The Backup Machine (an Atlassian solution using AWS Lambda and SQS to coordinate the backup process)
Disable Email Sending/Receiving
Unless your live Jira instance is down you will probably want to disable email sending/receiving before performing any restore
With your ssh environment setup for the target ASI Stack...
ssh $targetIPaddress
sudo su - root
service jira stop
Un-comment the following line in /bin/setenv.sh...
DISABLE_NOTIFICATIONS=" -Datlassian.mail.senddisabled=true -Datlassian.mail.fetchdisabled=true -Datlassian.mail.popdisabled=true"service jira start
Backup (AWS Native)
Backup Database
For production use, it is strongly recommended that for regular backups, you use native database backup tools instead of Jira's XML backup service.
When Jira is in use, XML backups are not guaranteed to be consistent as the database may be updated during the backup process. Jira does not report any warnings or error messages when an XML backup is generated with inconsistencies and such XML backups will fail during the restore process. Native database backup tools offer a much more consistent and reliable means of storing (and restoring) data while Jira is active.https://confluence.atlassian.com/adminjiraserver/backing-up-data-938847673.htmlRestore Database
*** Untested skeleton documentation ***
Restore a new database from a snapshot.
Update the CloudFormation Template ansible parameters:
-e atl_db_host=xxxxx
Find out more by looking at:
https://bitbucket.org/atlassian/dc-deployments-automation.git
aws_jira_dc_node.yml
aws_node_local.yml
Backup (Jira Native)
Backup Database (XML)
NOTE: To ensure the backup is consistent and complete you should prevent users from updating the system. If the system is updated after the backup starts data could be lost.Administration (cog) - System - Import & Export - Backup System
Enter an arbitrary filename and click Backup
This will create a zip file in /media/atl/jira/shared/export/ on the Jira node (this is an EFS filesystem so it should be visible from any Jira node)
Backup Database (PostgreSQL)
Backup from a Jira node.
If pg_dump is not installed (this is expected, unless you have done a backup from this node before) use these commands to install it...
sudo amazon-linux-extras enable postgresql11
sudo yum clean metadata
sudo yum install postgresql
Full backup of Jira schema...
pg_dump -h endpointofnewsnapshotinstance.rds.amazonaws.com -U atljira -W -f jirabackup.sql jira
The EFS drive is a good target for the backup file.Backup of just Insight objects...
pg_dump -h endpointofnewsnapshotinstance.rds.amazonaws.com -U atljira -W -t "\"AO_8542F1\"*" -f AO_8542F1.sql jira
Backup Data Directory
zip -r /tmp/datafilename.zip /media/atl/jira/shared/data/*
Backup Jira Index
The Jira index is stored in <Jira-home>\caches. On large instances, Atlassian recommend enabling 'restorable index' in the system options to create backups of the index that can be restored later.
Restore (Jira Native)
Restore Database
Administration (cog) - System - Import & Export - Restore System
Restore Database (PostgreSQL)
pg_restore -h endpointofexistinginstance.rds.amazonaws.com -U atljira -W -d jira -v -c jirabackup.sql
Restore Data Directory
Restore Project
Your backup file must have been created using Jira's (XML) backup tool. You cannot import a project from a backup using your native database tools.
https://confluence.atlassian.com/adminjiraserver/restoring-a-project-from-backup-938847691.htmlNote that due to the limitations of the XML backup described earlier, the ability to restore a Project should not be seen as normal capability. In the event that a single Project needs to be moved from one instance to another then a specific XML backup should be taken for this purpose. For creation of a test environment containing all Projects then complete native database restores are more suitable.
Backup (Backup Machine)
The Backup Machine is a non-chargeable Atlassian provided (community supported) Backup tool to simplify the backup process in AWS.
Installation
Assumptions
Your AWS user has the AdministratorAccess policy.
Python 3 is installed
aws iam list-user-policies --user-name myuser
aws iam list-groups-for-user --user-name myuser
aws iam list-attached-group-policies --group-name mygroup
python3 --version
Installation
Clone a local copy of the Backup Machine Bitbucket repository...
cd ~
git clone https://bitbucket.org/atlassian/aws-backup-machine.git
cd aws-backup-machine
Create an S3 bucket...
region=eu-west-2
bucket=wpe-backmac-deployment-$(aws sts get-caller-identity --output json | grep Account | awk -F'"' {'print $4'})-${region}
aws s3 mb s3://${bucket} --region ${region}
Change your region as appropriate. Note that having the bucket name end with the region is a mandatory requirement of the Backup Machine configuration../package.sh "${region}"
If you have chosen not to use the default S3 bucket name above you can enter a custom name above as argument 2 to package.shIn the AWS Console, navigate to CloudFormation and Create Stack.
Select "Template is ready"
For the Template Source select "Amazon S3 URL" and provide the URL of the Quick Start template in your S3 bucket.
Use the command below from the Linux shell prompt to generate a URL that you can cut & paste.
echo https://${bucket}.s3.${region}.amazonaws.com/Backmac.template.yaml
Specify stack details, referring to the Parameter Guide below...
Tagging a Stack for Backup
In order for BackMac to backup a stack on the specified schedule, the target stack must be tagged with backmac_enabled=true.
Do this by performing an Update on the target Cloudformation stack (using current template). Leave all parameters unchanged but add the tag at step 3...
Confirm the tag is set using the Tags section of the Stack Info tab for your target stack.
Once the stack update is complete, the Bastion server will be tagged with backmac_enabled=true but the Jira nodes will not. Assuming they are in an autoscaling group with a minimum of two nodes you should terminate the instances in turn (wait for the first to automatically come back online before terminating the second). Once instances are recreated via this method the tag will be set.
Restore (Backup Machine)
*** PROCEDURE NOT YET TESTED OR DOCUMENTED ***
Bibliography
https://jira.atlassian.com/browse/JRASERVER-67265 (Document backup and restore steps when running JIRA Data Center in AWS)
Backuphttps://confluence.atlassian.com/adminjiraserver/backing-up-data-938847673.htmlhttps://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html
Restorehttps://confluence.atlassian.com/adminjiraserver/restoring-data-938847686.htmlhttps://confluence.atlassian.com/adminjiraserver/restoring-data-from-an-xml-backup-938847707.htmlhttps://confluence.atlassian.com/adminjiraserver/restoring-a-project-from-backup-938847691.htmlhttps://community.atlassian.com/t5/Answers-Developer-Questions/How-can-I-programmatically-restore-JIRA-to-a-new-machine/qaq-p/558363https://community.atlassian.com/t5/Jira-questions/How-to-restore-JIRA-from-a-full-database-backup/qaq-p/46082https://confluence.atlassian.com/adminjiraserver/switching-databases-938846867.html https://stackoverflow.com/questions/32255309/how-do-i-restore-rds-snapshot-into-a-cloudformation https://confluence.atlassian.com/adminjiraserver/configuring-file-attachments-938847851.htmlhttps://confluence.atlassian.com/adminjiraserver/jira-application-home-directory-938847746.html
Backup Machinehttps://community.atlassian.com/t5/Data-Center-articles/Introducing-Atlassian-CloudFormation-Backup-Machine/ba-p/881556https://bitbucket.org/atlassian/aws-backup-machine/src/master/
Discussion about "the Backup Machine" starts at 19:03.