Fix Bitbucket Data Center repository export failure due to dangling symlinks
Platform Notice: Data Center Only - This article only applies to Atlassian apps 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
Bitbucket repository exports fail with an error stating that metadata.atl.tar cannot be added to the export archive. This occurs in Atlassian Bitbucket Data Center when dangling symlinks exist in the repository storage directory.
Diagnosis
This issue affects Bitbucket Data Center environments where repositories have been modified by external tools like SubGit, or where manual file system changes have introduced symlinks.
Cause
The Bitbucket migration export process walks through the repository metadata to create an export archive. If the repository storage directory contains a dangling symlink (a link pointing to a non-existent path), the Java process encounters a java.nio.file.NoSuchFileException. Because the file referenced by the symlink cannot be read, the creation of the metadata.atl.tar file fails, halting the export.
Solution
To resolve this issue, you must identify and remove any dangling symlinks within the affected repository storage directory on the Bitbucket server.
Confirm the issue and identify the affected repository
Review the Bitbucket application logs (atlassian-bitbucket.log) for an error similar to the following:
Note the <REPO_ID> and the specific path mentioned in the NoSuchFileException.
com.atlassian.bitbucket.migration.ExportException: Failed to add entry 'com.atlassian.bitbucket.server.bitbucket-git_git/repositories/<REPO_ID>/metadata/metadata.atl.tar' to the export archive
...
Caused by: java.nio.file.NoSuchFileException: /var/atlassian/application-data/bitbucket/shared/data/repositories/<REPO_ID>/svn
Verify and remove dangling symlinks
Log in to the Bitbucket server terminal.
Navigate to the repository storage directory identified in the log:
cd <BITBUCKET_HOME>/shared/data/repositories/<REPO_ID>List all files, including hidden ones, and check for symlinks:
ls -laIdentify symlinks (indicated by l at the start of the permission string, e.g., lrwxrwxrwx).
Check if the symlink is dangling by attempting to list the target path or using the file command: If the output says "broken symbolic link", it must be addressed.
file <symlink_name>Remove the dangling symlink:
rm <symlink_name>Retry the repository export via the API or UI.
Was this helpful?