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
Hi Everyone - glad you were able to get this resolved. I do admit that from my understanding of the scripts, they were a "best-effort" example of how you could create scrips to interact with the API, but arent officially maintained by Atlassian.
With that said, we are working to overhaul/improve the backup/restore experience, and if you'd like to be part of that journey, I'd like to invite you to join our closed group to provide feedback on our future direction.
https://community.atlassian.com/t5/Backup-Restore/gh-p/backupandrestore
Just click that link, request access, and we'll get you in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Moga,
I got it to work and the permission was the issue. Originally I tried with my account, however I got no response whatsoever from the script. Then I asked my manager (who has more privileges than I do) to generate a token. Then I replaced my token and email address with his and the script worked. Unlike my token, this time the script showed the progress and informed me when it started the download. I do think a permissions error message would be helpful for customers trying this in the future.
Would you happen to know the exact permissions needed to be able to do a JIRA backup? I have never tried to generate the XML backup on the Cloud instance before. Do you have a link on how to do that?
Thank you
Felipe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Felipe Velasco,
If not mistaken, you will need Site Admin privilege to generate the backup.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.