Jira REST API Backup with Powershell

Austin Luu July 26, 2019

Hello,

I'm having some issues try to create a session and then creating a backup with the rest api through powershell. Below is my code, can anyone see what I'm doing wrong? Appreciate any advice!

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$user = 'austin.luu91@gmail.com'
$pass = #API Token
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}

Invoke-WebRequest -UseBasicParsing -Method Post -Uri "https://15sof1.atlassian.net/rest/auth/1/session" -Headers $headers -SessionVariable session -ContentType 'application/json'
$InitiateBackup = Invoke-RestMethod -Method Post -Headers @{"Accept"="application/json"} -Uri "https://15sof1.atlassian.net/rest/backup/1/export/runbackup" -WebSession $session -ContentType 'application/json' -Body $bodyjson -Verbose | ConvertTo-Json -Compress | Out-Null

1 answer

1 accepted

1 vote
Answer accepted
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 29, 2019

Hello Austin,

We do have a PowerShell script which can be used to backup cloud instances. This script is within Bitbucket and is publicly viewable. Please take a look at the following (You’ll need to add the top variables to your script to make it work).

If you have any issues with this script, please let us know.

Regards,
Stephen Sifers

Austin Luu July 30, 2019

Worked like a charm, thanks for your help!

Like Stephen Sifers likes this
zakaria November 19, 2019

can you send me the backup.ps1 ??

jabr.zakaria@gmail.com

 

merci 

Like Stephen Sifers likes this
Test ddn November 20, 2019

Hi the script mentioned above via link is not available now. can you please share that gain

Thanks

Chandra

Like Stephen Sifers likes this
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 20, 2019

Hello Everyone,

We did rename the files used within the scripts to better clarify what products they work with. Since we did that it broke the link above. I have corrected the link above and you should be able to see the available backup scripts by their product now.

Regards,
Stephen Sifers

Srini March 6, 2023

Hi @Stephen Sifers ,

 

Are we still using the above mentioned scripts or any new method came in for automating Jira cloud backups?

 

Thanks.

Anja Calhoun March 6, 2023

Hello @Stephen Sifers 

Is there a similar script for data restore?

The import UI has the following:

 image.png

Seems like there is some amount of manual work that needs to be done?

Typically we won't be deleting data in the entire site, perhaps we want to recover back specific issues, attachments or configuration objects such as workflows etc..

Is there a was we can restore back data in a granular manner using a script?

 

Thank you for your advice.

Srini March 6, 2023

@Austin Luu HI , Do you have step by step guide to run this script?

Suggest an answer

Log in or Sign up to answer