To copy single repository from old instance to new

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.

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

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?

Regards
Bharat

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

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 evironment.

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 ?

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

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

2 Likes

hi @bharatpmalge

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

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

@bharatpmalge
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!!

Did you find the soltution because I am stuck there.

@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.

1 Like

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

@klau,
thanks for the answer, do you have any idea of when this release will be comming out?
Just saw that 3.23 was released this month.
Thanks

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