How to export attachments from JIRA OnDemand and JIRA Cloud

At one of the customers sites we are using JIRA OnDemand (A.K.A JIRA Cloud now) to track our BSM tasks and cost estimates, which we provide for a planned piece of work and these exist in JIRA as Excel files attached to tasks.

As the end of financial year is coming close here in Australia I was asked by my manger to send him these cost estimates for the last financial year. Trying to do it manually one by one from the Web UI for a couple of them made me think that there must be a better way to accomplish that. Google search did bring a few results but they were relevant to on premisses hosted JIRA solution where you had access to the command line.  These didn’t suit me. So after playing around a little I came up with the solution described below. If you have a Linux machine (and a know how) you could probably achieve that in a couple of lines but I only had access to my Windows machine at that time . In addition to a Windows machine  you will need  Notepad++.

Export JIRA backup

  • In the JIRA OnDemand interface navigate to JIRA Administration > System
    JIRA_Administration
  • Under the Import and Export click Backup manager
    JIRA_ImportExport.jpg
  • On the Backup manager page verify that Back up attachments is checked and click Create Backup
    JIRA_BackupManager_Before
  • Once the backup is done a link to download the backup archive will be visible.
  • Download the file and unzip it to a temporary folder (I’ve used C:\Temp).JIRA_BackupManager_After



Extracting attachments’ file names

  • Open the  C:\Temp\JIRA-backup-20140605\entities.xml  with Notepad++
  • Search the file for all the lines that have following text: FileAttachment
  • JIRA_NP_Find
  • The result will be shown in the “Find result” pane
  • JIRA_NP_Find_Result
  • Open a new file in Notepad++ and copy all the content from “Find result” pane
  • Run the following replace:
    .+id=”(\d+)”.+filename=(“.+?”).+
    ren \1 \2
  • JIRA_NP_Replace
  • As a result you will have somthing simmilar to the below:
  • JIRA_NP_REN
  • Remove all the lines that don’t start with “ren”



Copy files from all subfolders to a single folder

  • The attachments are located in the <BACKUP_ARCHIVE_FILE>\data\attachments folder (in our case it’s C:\temp\JIRA-backup-20140605\data\attachments)
  • Open a command prompt:
  • Change current directory to the attachments one
    cd C:\temp\JIRA-backup-20140605\data\attachments
    Note: if you are interested only in attachments from a specific project then type cd C:\temp\JIRA-backup-20140605\data\attachments\<PROJECT_NAME> instead of the above.
  • Create an output folder (if you are interested only in attachments from a specific project
    md c:\temp\JIraAttachments\
  • Copy files form all the projects into the output folder
    for /R %b in (.) do @copy %b\*.* c:\temp\JIraAttachments\
  • Change the current directory to the output directory
    cd c:\Temp\JIraAttchments
  • Rename the files (just copy and paste the content of the text file from Notepad++
    ren 10601 “Cost Estimation 1.xlsx”
    ren 10303 “ALM Cost Calculator.xlsx”
    ren 10304 “App Instrumentation – BPE.pptx”
    ren 10604 “BPE Approval.msg”
    ………….
  • The result is that you have all the attachments in one folder. By the way the attributes (like Date Modified) are kept
    JIRA_Result



16 thoughts on “How to export attachments from JIRA OnDemand and JIRA Cloud”

  1. Hi there,

    With JExcel PRO you can export comments images and other attachments with the issues from JIRA to Excel or HTML.

    You can find it on the Atlassian Marketplace: https://marketplace.atlassian.com/plugins/com.moresimp.jexcel.pro/server/overview

    If you want to use it on the Cloud, check out our Cloud solution: http://moresimp.com/hosting
    (In some parts, it is better than the Atlassian Cloud.)

    Try it and let me know how you like it! 🙂

    Thank you.

    Mark

    1. HI Mark,
      There are a few way/plugins to achieve the export on self-hosted aka Server Jira instances and your looks nice on the marketplace (haven’t tried it).
      Saying that, my issue was that we had a Cloud (Atlassian) hosted Jira instance….

      Regards,
      ILYA

  2. Thank You Ilya, this was very helpful.

    I modified this a bit in order to keep each attachment in the folder of each Jira item.

    Thanks,
    Christina

      1. Hi Chintak,
        I don’t think that the files stayed within their folders.
        As you can see in “Copy files from all subfolders to a single folder” step we are actually moving them to a single output folder.
        Do you require them to stay within their own folder?

        Regards,
        ILYA

  3. Hi Ilya,

    Thank you very much for this

    I’m hoping you can help me.

    When I get to this step

    Run the following replace:
    .+id=”(\d+)”.+filename=(“.+?”).+
    ren \1 \2

    I get an error “Can’t find text .+id=”(\d+)”.+filename=(“.+?”).+, is there a solution for this please?

    Many thanks

      1. Hi Ilya,

        i have the same problem. Regular rexpression is selected. Any ideas?

        And thank you much for this artivle, it will safe hours of my time.

        Regards,

        Basti

  4. Hi IIya ,

    as you said above i have struck at the same line that is

    .+id=”(\d+)”.+filename=(“.+?”).+
    ren \1 \2

    its showing the error like ,
    “0” Occurances, were replaced , this is not replacing the values

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.