How to change the attachments directory on JIRA

Still need help?

The Atlassian Community is here for you.

Ask the community

Overview

As of JIRA 4.2, for security reasons, the ability to change the directory where attachments are stored has been removed. So, if you use any version between 4.2 and 5.1.x you'll have to manually change the attachments location property on JIRA's database. However, this won't work on any version of JIRA from 5.2 and beyond, in which this policy was enforced and JIRA will refuse saving attachments if a custom path is defined.

This document aims to provide some workarounds to be able to change the location of the attachments on any version of JIRA from 4.2 to the latest, in case you need to do so due to storage space constraints or any other reason.

tip/resting Created with Sketch.

 Please note this may affect JIRA's performance if there's any considerable delay on reading files from another drive (if the attachments are moved to a network drive, for example).

Workaround

JIRA 5.2 and above

Create a symbolic link on your server from the default attachment path ( <JIRA_HOME>/data/attachments ) to the path where you want your attachments to be stored.

Creating a symbolic link on Linux

Run the below command on the system's command line.

ln -s /path/to/file /path/to/symlink
Creating a symbolic link on Windows

Run the below command on the system's command line.

mklink /J C:\path\to\symlink E:\path\to\file

JIRA 4.2 to 5.1.x

All platforms

Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.

  1. Shutdown JIRA.
  2. Run the following SQL queries to change the directory:

    UPDATE propertystring
    SET propertyvalue='/path/to/attachments' 
    WHERE id IN (
        SELECT id FROM propertyentry WHERE property_key = 'jira.path.attachments'
    );
    

    Replace /path/to/attachments with the actual path where you want to have attachments saved. Make sure the user that runs JIRA has read and write permissions on the chosen folder.

    UPDATE propertynumber
    SET propertyvalue = 0
    WHERE id IN (
        SELECT id FROM propertyentry WHERE property_key = 'jira.path.attachments.use.default.directory'
    );
    UPDATE propertynumber
    SET propertyvalue = 1
    WHERE id IN (
        SELECT id FROM propertyentry WHERE property_key = 'jira.option.allowattachments'
    );
    tip/resting Created with Sketch.

    The above queries have been composed and validated on a PostgreSQL database and may need changes to its syntax for other DBMS.

  3. Start JIRA;
Last modified on Nov 12, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.