Atlassian are changing the way that they do Cloud backups

Issue #3 resolved
Antony Brooke-Wood created an issue

This has just started being rolled out and they don't really have much documentation on it. What is clear at the moment is that the WebDav approach is being retired. Obviously this will break all of the existing scripts like this repo. You can read a bit about it here: https://jira.atlassian.com/browse/CONF-45003

Comments (9)

  1. Antony Brooke-Wood reporter

    Hi,

    There is a work around posted here: https://jira.atlassian.com/browse/CONF-45015

    darren.bowen@thirdkindgames.com added a comment: I also used the bit bucket example for my script. https://bitbucket.org/atlassianlabs/automatic-cloud-backup/src/174a81f82577397b85b61de564b789466095fb1d/backup.sh?at=master&fileviewer=file-view-default

    However, I've since found a way to do this with the new system, in the wait for backup loop rather than attempting to download the file you can instead query its status to see if its complete. Fetch the following URL in the script https://$account.atlassian.net/wiki/rest/obm/1.0/getprogress

    This returns a json string with details of the backup. If the backup has completed it will have a fileName property which you can use to download the backup as follows:

    If it's still creating then the fileName property won't be there so you can continue to wait, e.g:

    Avoid some of the other properties like size (which is always zero) and currentStatus (which says 'Zipping export files' even though the backup is complete.)

  2. Antony Brooke-Wood reporter

    I've incorporated Darren's suggestion and it works. The script below will backup Cloud Confluence on the new backup mechanism. To backup Jira instead, you need to remove the references to 'wiki' in the URLs on lines 24, 29, 36 and 37.

    <# 
    DESCRIPTION: This script backs up Confluence from Atlassian Cloud.
    AUTHOR:      Antony Brooke-Wood
    SOURCE:      https://bitbucket.org/atlassianlabs/automatic-cloud-backup
                 https://github.com/ghuntley/atlassian-cloud-backup/blob/master/src/AtlassianCloudBackupClient/BackupClient.cs
    #>
    
    $account     = 'account'
    $username    = 'username'
    $password    = 'password'
    $destination = 'C:\destination'
    $attachments = $false
    $cronitor    = 'cronitor'
    
    $today       = Get-Date -format yyyyMMdd
    $credential  = New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))
    
    # Login
    Write-Host 'Logging in to Atlassian.'
    Invoke-WebRequest -Method Post -Uri "https://$account.atlassian.net/login" -SessionVariable session -Body @{username = $username; password = $password} | Out-Null
    
    # Request backup
    Write-Host 'Triggering backup.'
    Invoke-RestMethod -Method Post -Uri "https://$account.atlassian.net/wiki/rest/obm/1.0/runbackup" -WebSession $session -ContentType 'application/json' -Body (@{cbAttachments = $attachments} | ConvertTo-Json -Compress) | Out-Null
    
    # Wait for backup to finish
    Write-Host 'Waiting for backup generation to finish.'
    do {
        $status = Invoke-RestMethod -Method Get -Uri "https://$account.atlassian.net/wiki/rest/obm/1.0/getprogress" -WebSession $session
        $status.alternativePercentage -match "(\d+)"
        Write-Progress -Activity 'Creating backup' -Status $status.alternativePercentage -PercentComplete $Matches[1]
        Start-Sleep -Seconds 5
    } while(! $status.fileName)
    
    # Download the backup
    Write-Host "Downloading backup https://$account.atlassian.net/wiki/download/$($status.fileName)"
    Invoke-WebRequest "https://$account.atlassian.net/wiki/download/$($status.fileName)" -WebSession $session -OutFile (Join-Path -Path $destination -ChildPath "Confluence-backup-$today.zip")
    Write-Host 'Pinging Cronitor.'
    Invoke-WebRequest "https://cronitor.link/$cronitor/complete" | Out-Null
    Write-Host 'Backup complete.' -ForegroundColor Green
    
  3. Mike Barmettler

    Hi Antony,

    i tried to change the script to create and download the JIRA Cloud Backup. I changed the lines according your recommendation a few posts above (remove wiki in URLs).

    but i get a lot of errors and stuck in a endless loop. does the creation and download work for you - for JIRA Backup?

    thanks & best regards

  4. Antony Brooke-Wood reporter

    Hi Mike,

    I can't test the Jira backup yet. My Confluence instance is on the new method, but my Jira instance is not, so I am stuck with a mix of scripts. Do you know if you are on the new backup method or the old one for Jira? The way to tell is to initiate the backup by the web interface: https://YOURCOMPANY.atlassian.net/plugins/servlet/ondemandbackupmanager/admin Once it is complete, do you end up with a file like this: https://YOURCOMPANY.atlassian.net/webdav/backupmanager/JIRA-backup-20161030.zip. Or do you end up with something else? If you get the former, then you are on the old backup method and you should probably use the original script in this repo.

    If you can post the errors, I may be able to help.

  5. Mike Barmettler

    Hi Antony,

    thank you for your reply on this. manually it works as expected - create and download the JIRA Backup.

    I dont know how to check if i'm on the "new" way or on the old. How can i check that?

    but in Script - i dont know which REST Adress i have to use, to request a backup for JIRA.

    All the URLs you provided aare correct from my point of view.

    so i'm stuck on two points: * - request JIRA Backup - similar to the one to Confluence https://$account.atlassian.net/wiki/rest/obm/1.0/runbackup * - download the JIRA Backup (with your provided URL)

    thanks for you help & best regards Mike

  6. Antony Brooke-Wood reporter

    If your file is named like this JIRA-backup-20161030.zip then you are on the old method. If you're on the old method, you can't use my script because you won't get a filename returned when you check on the status of the backup. Instead, you have to use the original script in this repository.

    If you are on the new method, then you can use the above script, but because you are backing up Jira instead of Confluence, you need to remove the references to 'wiki' in the URLs on lines 24, 29, 36 and 37. So you line 24 for example, needs to be this: Invoke-RestMethod -Method Post -Uri "https://$account.atlassian.net/rest/obm/1.0/runbackup" -WebSession $session -ContentType 'application/json' -Body (@{cbAttachments = $attachments} | ConvertTo-Json -Compress) | Out-Null

  7. Mike Barmettler

    i tried to use the PS Script from the Repo here. but i cant get it to work for JIRA Backup.

    i think i'll wait until we are as well on the "new" way from Atlassian - so its as well the same script - except these small changes in the URL (which i could then parametrize as well to have only one script).

    thank you

  8. Log in to comment