Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA Backup script not working

I'm using the following script to try to backup JIRA

https://bitbucket.org/atlassianlabs/automatic-cloud-backup/src/master/Jira-backup.sh

I put in my personal information for the following fields:

EMAIL=
API_TOKEN=
HOSTNAME=
DOWNLOAD_FOLDER=

However, when I run the script it does not return anything.  There are no error messages whatsoever and no zip file is created.

I took a look at the script and found the following curl command:

curl -s -u ${EMAIL}:${API_TOKEN} -H "Accept: application/json" -H "Content-Type: application/json" --data-binary "{\"cbAttachments\":\"$INCLUDE_ATTACHMENTS\", \"exportToCloud\":\"$EXPORT_TO_CLOUD\"}" -X POST https://${HOSTNAME}/rest/backup/1/export/runbackup

This is the command that is supposed to start the backup and return something.  However, for me it returns nothing.

Am I doing something wrong? Any troubleshooting advice would be greatly appreciated

Thank you

Felipe

1 answer

Hi @Felipe Velasco,

Welcome to the Atlassian Community!

From the shell script, I can see that there are few echo commands. Can I know if you can see such lines on the command prompt?

TODAY=$(TZ=$TIMEZONE date +%d-%m-%Y)
echo "starting the script: $TODAY"


## The $BKPMSG variable is used to save and print the response
BKPMSG=$(curl -s -u ${EMAIL}:${API_TOKEN} -H "Accept: application/json" -H "Content-Type: application/json" --data-binary "{\"cbAttachments\":\"$INCLUDE_ATTACHMENTS\", \"exportToCloud\":\"$EXPORT_TO_CLOUD\"}" -X POST https://${HOSTNAME}/rest/backup/1/export/runbackup )

## Uncomment below line to print the response message also in case of no errors ##
# echo "Response: $BKPMSG"

Hello Mogavenasan,

Thank you for the reply!

When I do what you suggest I get no response for the variable, see below:

[root@localhost opt]# sh jira_backup_felipe_token.sh
starting the script: 09-02-2021
Response:
[root@localhost opt]#

Please let me know if there is anything else I should try

Thank you

Felipe

Heya @Felipe Velasco,

So I did a bunch of reading on the REST API being used within the script - it looks like the endpoint might have changed or it's not really an official endpoint. For reference, you can take a look at:

I hope that this helps

Thanks,
Moga

Thank you Moga for the research!

I'm a little confused however.  If the endpoints keep changing then is this backup script a viable way of doing backups?  If not, is there a better (recommended) way to do backups? 

If the current script is the best solution then how do I find out what the new endpoints are?  I don't see the new endpoints from the links you gave me.  

Also the links you gave me are from 2017 and 2013 , however the script that I had downloaded was form Dec 2019.  In the CLOUD-6498  link there is a workaround, however this workaround is the exact same script that I originally downloaded (the Dec 2019 script)

Am I missing something?

Thank you

Felipe

Hi @Felipe Velasco,

 If the endpoints keep changing then is this backup script a viable way of doing backups?  If not, is there a better (recommended) way to do backups? 

The script would not be a long term solution, to be honest. That's why there is an open feature request for this topic.

Out of curiosity, I tested the script and it worked:

moga@moga Downloads % chmod 777 Jira-backup.sh
moga@moga Downloads % ./Jira-backup.sh
starting the script: 12-02-2021
{"status":"InProgress","description":"Cloud Export task","message":"Preparing database for export (it may take up to 30 minutes)","progress":0,"exportType":"CLOUD"}
{"status":"InProgress","description":"Cloud Export task","message":"Preparing database for export (it may take up to 30 minutes)","progress":0,"exportType":"CLOUD"}
{"status":"InProgress","description":"Cloud Export task","message":"Preparing database for export (it may take up to 30 minutes)","progress":0,"exportType":"CLOUD"}
{"status":"Success","description":"Cloud Export task","message":"Completed export","result":"export/download/?fileId=7d137660-57f9-4d79-80cb-55d7edcc9e04","progress":100,"exportType":"CLOUD"}
Downloading https://xxx.atlassian.net/plugins/servlet/export/download/?fileId=7d137660-57f9-4d79-80cb-55d7edcc9e04

You might want to try a different machine or something. I can confirm that the script works on my machine.

Thank you Moga,

I setup a new server with no firewall and unrestricted access to the internet.  I then ran the script again and got no results again.  Maybe the user/token combination I'm using does not have enough permissions to download?  Or maybe there is an issue with the site I'm using?  I see no errors so it's really difficult to tell

Is there a way to troubleshoot this?

Thank you

Felipe

Hi @Felipe Velasco,

Are you able to generate the XML backup on the Cloud instance via the UI? If yes, then you have the permission and it should work via REST API as well. 

The cURL command will usually return some HTTP code which will tell us if something goes wrong.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,142 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you