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 REST API Backup with Powershell

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

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

Worked like a charm, thanks for your help!

Like Stephen Sifers likes this

can you send me the backup.ps1 ??

jabr.zakaria@gmail.com

 

merci 

Like Stephen Sifers likes this

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

Thanks

Chandra

Like Stephen Sifers likes this

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

Suggest an answer

Log in or Sign up to answer
TAGS

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