// Metadata created by nebel
// ParentAssemblies: assemblies/getting-started/as_managing-registry-artifacts.adoc

[id="migrating-registry-data_{context}"]
= Migrating {registry} data

[role="_abstract"]
Migrating data to {registry} 3.x requires exporting all data from your existing {registry} 2.x deployment and importing it into the new 3.x deployment. If you are using {registry} as a schema registry for Kafka applications, data migration is critical because each Kafka message carries the global identifier for the schema stored in {registry}. This identifier must be preserved during registry data migration.

Both {registry} 3.x and 2.x provide an API to bulk import/export all data from your registry deployment, which guarantees that all identifiers are kept when importing data from your existing registry. The export API downloads a custom `.zip` file containing all the information for your artifacts. The import API accepts this `.zip` and loads all artifacts into the registry in a single batch.

The {registry} 3.x import feature is able to import `.zip` contents created from either a 2.x or 3.x deployment.

.Prerequisites 
* Running a {registry} instance of the 2.x server you are exporting from and the 3.x instance you are importing into.

.Procedure

. Export all the data from {registry} 2.x using the Export feature, which can be accessed from the UI or the REST API. This generates a `all-artifacts.zip` file in a directory of your choice.
. Import the `.zip` file into {registry} 3.x using the import API:
+
[source,bash, subs="attributes+"]
----
curl -X POST "http://new-registry.my-company.com/apis/registry/v3/admin/import" \
  -H "Accept: application/json" -H "Content-Type: application/zip" \
  --data-binary @all-artifacts.zip
----

. Check that all the artifacts have been imported into the new 3.x registry by running these commands and comparing the count field:
+
[source,bash, subs="attributes+"]
----
curl "http://old-registry.my-company.com/apis/registry/v2/search/artifacts"
----
+
[source,bash, subs="attributes+"]
----
curl "http://new-registry.my-company.com/apis/registry/v3/search/artifacts"
----

[role="_additional-resources"]
.Additional resources
* For more details on the import/export REST API, see 
ifdef::apicurio-registry[]
{managing-registry-artifacts-api}
endif::[]
ifdef::rh-service-registry[]
the link:{LinkServiceRegistryUser}#exporting-importing-using-rest-api[{NameServiceRegistryUser}].
endif::[]
