Change the attachments directory location for Jira server

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

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
  • Replace <Jira_home> on the samples below with the full path to your Jira home location;
  • Move the content of <Jira_home>/data/attachments to the new location, for instance, under /Users/imurakami/newloc/
cd <JIRA_HOME>/data/attachments
mv * /Users/imurakami/newloc/


  • Run the below command on the system's command line.
ln -s /path/to/file /path/to/symlink

On our sample:
sudo ln -s ~/newloc/ <Jira_home>/data/attachments


  • Now, inside <JIRA_HOME>/data folder, instead of seeing the folder attachments, you will only see the symbolic link to the new location. There should not have an attachments folder under <jira_home>/data otherwise system will find the existing attachments directory first and not the attachments symlink. 

  • Adjust the owner, group, and required permissions to allow the user used to start Jira to access the location.
cd <Jira_home>/data
chmod -R 755 newloc
sudo chown -R jira *
sudo chgrp -R jira *

cd /Users/imurakami
chmod -R 755 newloc
sudo chown -R jira newloc
sudo chgrp -R jira newloc

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 29, 2022

Was this helpful?

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