Manually migrate LFS objects between two Bitbucket DC instances
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
Sometimes we want to use the migration tool to export repositories from a Bitbucket instance to another. If that’s the case, one of the tool’s limitations is that it doesn’t migrate LFS objects, which needs to be performed manually. Here we describe the steps needed to migrate these objects using git and git lfs.
Solution
We need to perform a mirror clone from Source Bitbucket instance. This would be the needed set of steps:
Create a new empty repository on the Destination Bitbucket instance.
Make sure that, under repository settings, LFS is enabled.
On a local machine, create a new working folder:
mkdir lfs-migrationEnter the folder and clone the repository from the Source Bitbucket instance:
git clone --mirror <source-repository-url>Enter the created directory: cd <repository-name>
Make sure that Git LFS is setup in the cloned repository:
git lfs install --localPull all the LFS objects from the Source Bitbucket instance (this is probably going to take a while):
git lfs fetch --allChange the LFS URL to the Destination Bitbucket instance:
git config lfs.url <destination-bitbucket-url>/<project-name>/<empty-repository-name>.git/info/lfsSet the new remote URL:
git remote set-url origin <destination-bitbucket-url>/<project-name>/<empty-repository-name>.gitPush all the regular Git objects to the new origin:
git push --all originPush all the LFS objects (this is also going to take a while):
git lfs push --all <destination-bitbucket-url>/<project-name>/<empty-repository-name>.git
This should migrate all the objects to the Destination Bitbucket. After the process is finished, please create a new folder and try cloning the new repository and see if the LFS objects are downloaded successfully.
Was this helpful?