To copy single repository from old instance to new - Sonatype Nexus Repository - Sonatype Community

To copy single repository from old instance to new

post by bharatpmalge on Apr 24, 2019

Hi,

We were using nexus on one server with lot of repositories within single blob, now we decided to have latest version of nexus on new server with same repos but with multiple bolbs (like 7-8 depending on artifact type).

We have installed new Nexus instance on new server. Now we want to migrate specific (single) repository to new server.

Let’s say one repository name is stratone (Source URL - http://nexusdev:8081/repository/straone/) which has releases and which we want to migrate as is on new instnace with same name stratone (Destination URL - http://nexusprod:8081/repository/straone)

How can we achieve this.

Thank you for your help.

post by jtom on Apr 26, 2019

I believe you want https://issues.sonatype.org/browse/NEXUS-11468 which is not yet completed.

In your case, it is worth noting the entire data directory is portable, so you could move everything and then remove what you don’t want as a possible workaround.

Regards,

Joe

post by bharatpmalge on Apr 29, 2019

Actually We have configured new instance to next level now so again copying entire directory and configuring from start will not be possible.

Can I do this?

Copy default blob in which we have all the data in old instance to new nexus server. If yes how can we achieve this?

post by jtom on Apr 29, 2019

I’m afraid I don’t understand your reply.

You say something won’t be possible then ask if you can do something?

You can copy the blobstore but also need to copy the database, otherwise you’ll be out of sync, so if you cannot copy the data directory, then the answer is probably no.

While not what you’re asking https://help.sonatype.com/display/NXRM3/Upgrading#Upgrading-Upgradingfrom2.xto3.y may help better explain. The concepts of move and (restoring from) backup are similar…basically the database and blobstore rely on each other, so if you move one, you need to move the other. If you do this but it’s not at the same time, you’ll likely have issues.

-Joe

post by bharatpmalge on Apr 30, 2019

Thanks for the reply Joe,

I was wondering, if I can copy a single blob (default) from old instance to new one.

But now I understood is that we have to copy the database as well.

So it won’t work in our environment.

post by bharatpmalge on Apr 30, 2019

Also, are you aware about any scripts which can be written with respect to rest API and we can download the (maven hosted) repo programatically and uploading it to new repo on new instance ?

post by jtom on Apr 30, 2019

I’m not but this question seems to come up, so this a good place, to have asked and/or you might look at older posts to see if anyone has posted them.

Aside from scripting, I have heard proxying can also be a solution (proxy the repo, run the builds, add the proxy with a new hosted to a group, then use the group). Not sure if that will work for you. -Joe

post by bharatpmalge on Nov 25, 2019

We wrote, an script using rest api which fetches the artifacts from release repos and uploads it to the new instance.

It works with all repo types, maven, npm, nuget

post by prabinliant on Feb 11, 2020

hi @bharatpmalge

May I know how you did it, it will be of more help for us.

post by aweinrich on Feb 11, 2020

Prabinliant,

The scripting approach might use the Assets API to list out contents of a repo and downloaded them to disk. Then they can be published to the new repos. Uploading approach likely varies per format. If users want to share their scripts we’d we’d be glad to host them in a repo for the community.

Some older ‘scripts’ to handle the importing/uploading are available under github import scripts

NPM would look something like:

curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/assets?repository=npm-old' 2>/dev/null | jq -c -r '.items' | jq .[].downloadUrl | xargs wget -P ./downloads
npm login --registry http://localhost:8081/repository/npm-new/
npmimport.sh -r http://localhost:8081/repository/npm-new/

Also, if you are not in a rush I believe there are plans for a productized import/export functionality later this year! -Adam

post by kaleblucasalves on Apr 17, 2020

Hello, could you share your solution? I’m also struggling with this task. I need to move almost all my repositories components from my nexus 3.2.0-01, to another one (3.15.2.-01). I saw that copying the db and the blobs directories works, but this would replace all the components, and I dont need all of them.

Thanks!!

post by nehait3047 on May 22, 2020

Did you find the solution because I am stuck there.

post by klau on May 22, 2020

@kaleblucasalves

We will be releasing Export for Raw and Maven in 3.24.0. If you are a pro customer, you will be able to export any raw and maven repositories from one Nexus 3 instance and then import them in another Nexus 3 instance.

post by nehait3047 on May 22, 2020

Hi, Can you please share the script for migrating data from one nexus3 to another nexus3 using script

post by kaleblucasalves on May 22, 2020

@klau,

thanks for the answer, do you have any idea of when this release will be coming out?

Just saw that 3.23 was released this month.

Thanks

post by klau on May 25, 2020

@kaleblucasalves we are planning 3.24.0 for the first half of June.

post by manoj.pachigolla on Jun 12, 2020

Hi @klau

We are planning to migrate few repos from 3.11 to 3.19 Version of Nexus.

Is there any possible way to migrate selected REPOS from the Nexus rather than copying the complete content.

Thanks

post by jtom on Jun 12, 2020

(speaking up for Kam)

There’s no in product way to do this until 3.24 and the professional (licensed) product.

We (almost) always recommend upgrading to latest anyway, I know some companies are restricted but you’re upgrading into an older version, I think of it like you are upgrading into known and fixed issues.

Depending on your scenario, using the REST API might be possible but no experience with that here.

Best,

Joe

post by Shake76 on Aug 13, 2020

Hi there,

I have to migrate from a very old nexus repository (1.4.x) to a new one in AWS (latest version if it is possible), I just was wondering now which requirements or dependencies should I follow to accomplish this task, is there any guidance in which I can take a look? (Documentation) any input will be much appreciated.

Regards

post by mpiggott on Aug 13, 2020

The first step needs to be upgrading your current setup to the latest version of Nexus 2 (backup first of course).

Then look at the migration to Nexus 3 - https://help.sonatype.com/repomanager3/installation/upgrading-from-nexus-repository-manager-2