Change the attachments directory location for Jira server
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.
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).
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.
JIRA 4.2 to 5.1.x
Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.
- Shutdown JIRA.
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' );
/path/to/attachmentswith 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' );
The above queries have been composed and validated on a PostgreSQL database and may need changes to its syntax for other DBMS.
- Start JIRA;