Removing a Custom Field from an XML Backup
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Summary
If information from a custom field created by a third-party app needs to be imported into another system but the third-party app is no longer available or is not compatible with the version of Jira in use, sometimes it must be removed completely from the XML backup in order for the import to succeed. This article details how to strip the information out of an XML backup.
⚠️ It is very possible to corrupt your XML backup this way if you choose the wrong custom field ID. Double-check that you have the right information on a test system before performing any kind of manipulation like this with a production system.
Environment
8.20.11 or later
Diagnosis
When attempting to import the XML backup, you receive an error stating "No custom field for customfield_#####. This should not happen. Data is likely to be corrupt."
Running the Integrity Checker on your current Jira instance and exporting a fresh XML backup does not resolve the issue
Deleting it via API with a DELETE call like "curl -X DELETE -u username:password -H "Content-Type: application/json" -k -v https://yourjira.com/rest/api/2/customFields?ids=customfield_#####" does not resolve the issue. (Only available in Jira Data Center)
Cause
A third-party app has corrupted custom field information in the database and Jira is not able to clean it up on its own. In order to fully clear out the Custom Field information in the XML you'll need to delete the custom field definition, as well as all of the references to it in the file.
You need to remove a custom field from your XML backup before importing it in to another system.
Solution
Removing a Custom Field from an XML Backup
Go to Administration ⚙ > System > Backup System
Generate the backup zip file in your
$jira-home/atlassian-jira/export
folder, then unzip itRun the following command:
grep -v
"<CustomField id=\"
#####
" entities.xml | grep -v "
customfield=\
"#####"
| grep -v
"customfield_#####"
> grepped-entities.xml
(Please change the '#####' to the custom field ID number in question on your system.)
Move the original
entities.xml
to a safe location.Rename
grepped-entities.xml
toentities.xml
Zip
activeobjects.xml
and your newentities.xml
together and load this backup zip into$jira-home/atlassian-jira/import
on your target system.Restore from the XML backup on your target system.
When the restore is complete, go toAdministration ⚙>System>Integrity checkerand run it with all the options checked. Fix any errors that come up.
Was this helpful?