I changed the token last friday in the morning, then I executed my Jira backup script, and it worked.
But since tonight it is returning:
{"error":"This feature is only accessible from the UI."}For instance, when I try to access to
https://<my site>.atlassian.net/rest/backup/1/export/lastTaskId
then I get that error message. I have tested it with 2 different sites, and both are returning que message.
Is anyone else having this issue?
My backup script is:
#General backup settings
$username = '<my_admin_acount@my_domain.es' # username with domain something@domain
$token = 'my_token' # Token created from product https://id.atlassian.com/manage-profile/security/api-tokens
$destination = 'C:\My_folder\Backup' # Location on server where script is run to dump the backup zip file.
$attachments = 'true' # Tells the script whether or not to pull down the attachments as well
$cloud = 'true' # Tells the script whether to export the backup for Cloud or Server
$today = Get-Date -format yyyyMMdd-hhm
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
if(!(Test-Path -path $destination)){
write-host "Folder is not present, creating folder"
mkdir $destination #Make the path and folder is not present
}
else{
write-host "Path is already present"
}
#Convert credentials to base64 for REST API header
function ConvertTo-Base64($string) {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);
$encoded = [System.Convert]::ToBase64String($bytes);
return $encoded;
}
$b64 = ConvertTo-Base64($username + ":" + $token);
$auth = $b64;
$string = "cbAttachments:true, exportToCloud:true"
$stringbinary = [system.Text.Encoding]::Default.GetBytes($String) | %{[System.Convert]::ToString($_,2).PadLeft(8,'0') }
$body = @{
cbAttachments=$attachments
exportToCloud=$cloud
}
$bodyjson = $body | ConvertTo-Json
if ($PSVersionTable.PSVersion.Major -lt 4) {
throw "Script requires at least PowerShell version 4. Get it here: https://www.microsoft.com/en-us/download/details.aspx?id=40855"
}
# Create header for authentication
[string]$ContentType = "application/json"
#Create Header
$header = @{
"Authorization" = "Basic "+$auth
"Content-Type"="application/json"
}
# Specific backup settings for every jira/confluence
$account = 'my_site_name' # Atlassian subdomain i.e. whateverproceeds.atlassian.net
# Create header for authentication
[string]$URI = "https://$account.atlassian.net/rest/backup/1/export/runbackup"
# Request backup
try {
$InitiateBackup = Invoke-RestMethod -Method Post -Headers $header -Uri $URI -ContentType $ContentType -Body $bodyjson -Verbose | ConvertTo-Json -Compress | Out-Null
} catch {
$InitiateBackup = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($InitiateBackup)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
}
$responseBody
$GetBackupID = Invoke-RestMethod -Method Get -Headers $header -Uri https://$account.atlassian.net/rest/backup/1/export/lastTaskId
$LatestBackupID = $GetBackupID
# Wait for backup to finish
do {
$status = Invoke-RestMethod -Method Get -Headers $header -Uri https://$account.atlassian.net/rest/backup/1/export/getProgress?taskId=$LatestBackupID
$statusoutput = $status.result
$separator = ","
$option = [System.StringSplitOptions]::None
$s
if ($status.progress -match "(\d+)") {
$percentage = $Matches[1]
if ([int]$percentage -gt 100) {
$percentage = "100"
}
Write-Progress -Activity 'Creating backup' -Status $status.progress -PercentComplete $percentage
}
Start-Sleep -Seconds 5
} while($status.status -ne 'Success')
# Download
if ([bool]($status.PSObject.Properties.Name -match "failedMessage")) {
throw $status.failedMessage
}
$BackupDetails = $status.result
$BackupURI = "https://$account.atlassian.net/plugins/servlet/$BackupDetails"
Invoke-WebRequest -Method Get -Headers $header -WebSession $session -Uri $BackupURI -OutFile (Join-Path -Path $destination -ChildPath "$account-backup-$today.zip")
And this is its current output:
PS C:\WINDOWS\system32> C:\My_folder\Backup\Backup_jira.ps1
Path is already present
DETALLADO: POST with -1-byte payload
{"error":"This feature is only accessible from the UI."}
Invoke-RestMethod : Error en el servidor remoto: (403) Prohibido.
En C:\My_folder\Backup\Backup_jira.ps1: 71 Carácter: 16
+ ... tBackupID = Invoke-RestMethod -Method Get -Headers $header -Uri https ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod : Error en el servidor remoto: (403) Prohibido.
En C:\My_folder\Backup\Backup_jira.ps1: 77 Carácter: 15
+ ... $status = Invoke-RestMethod -Method Get -Headers $header -Uri https ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Hi Admin - Atlassian has deprecated the backup APIs so your script will no longer work.
https://community.atlassian.com/forums/Jira-questions/Backup-Manager-API-deprecation-is-there-going-to-be-a/qaq-p/3120079#:~:text=David%20Malko,alternative%20for%20Standard%20plan%20users: has more details on it.
If you need to continue to do this automatically, you can use a third party app like Rewind (disclosure I'm the CEO). We're working on an API that would allow you to maintain your current functionality - it will be ready this quarter.
It sure was nice of Atlassian to send an EMAIL notice BEFORE they crippled our risk management implementation!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mike -
Does Rewind use a documented api to do the backup automation, or is it some kind of secret one only for partners?
I'm struggling to understand why a 3rd party app is needed for a basic like this.
Cheers,
Simon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Simon
Rewind uses public APIs but not the backup APIs that others were using. We use the public apis for each resource. That means we track each individual item compared to the snapshot that the backup APIs were providing.
For customers that means they can roll back one item rather than having to lose the work that’s happened since the backup. One Jira issue. One confluence page. One Jira project etc…. Doesn’t matter - we bring back whatever is causing problems and leave the rest of the data in tact.
You could build this yourself as well - but it’s difficult to map the API, understand it well enough to restore dependent items, and and keep it up to date with API changes.
Hope that helps explain the difference. Let me know if you have other questions.
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it - thanks for the comprehensive reply, I appreciate the detail. Sounds like it's a bit more than a simple backup/restore.
Cheers,
Simon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes a bit more than simple backup and restore. And this week we announced the release of Hot Standby, allowing you to replicate your data in another region.
We're a team of 100 people - you don't get to this size building simple backup and restore products. Rewind seems easy - the best solutions are often things that make hard things seem easy.
Mike
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.