How to import access data?

Ino Choi
2020-05-06 21:58

Subject 

When you migrate/import an Artifactory instance, your access data, which contains Users, Groups, Permissions and Access Tokens, will be imported as well.

However, if the access data fails to import into the new Artifactory instance or if you only want to import the access data, you can follow the following steps to manually export and import the access data.

Affected Versions

Artifactory 5.6 – 7.X

Resolution

1. You need the access-admin credentials in Artifactory. This account uses a randomly generated password in fresh installations. If you are unable to obtain the access-admin account credentials, follow the guides on our wiki:

– Artifactory 7.xChange default password for admin user

– Artifactory 6.xChange default password for access-admin user

2. Create a backup of the access data

Artifactory 7.x: Creates an access.backup.<TIMESAMP>.json file with the Access configuration as $JFROG_HOME/artifactory/var/backup/access

curl -uadmin:password -XPOST "http://localhost:8082/access/api/v1/system/backup/export"

Artifactory 6.x: Creates an access.backup.<TIMESAMP>.json file with the Access configuration as $ARTIFACTORY_HOME/access/backup

curl -uaccess-admin:password -XPOST "http://localhost:8040/access/api/v1/system/backup/export"

3. Replace the service ID in the access data backup file

– Find the service ID of both old and new Artifactory instances. 

– Up to version 5.5.1, the Artifactory service ID is formatted jf-artifactory@<id>. From version 5.5.2 the service ID is formatted jfrt@<id>.

– Sample output

curl -uadmin:password -XGET "http://localhost:8081/artifactory/api/system/service_id"  200jfrt@01e2rdwgsq8k8c1mbtvdav04xg

– Replace the old service ID with the new service ID everywhere in the access.backup.<TIMESAMP>.json file. Modify the Source Artifactory's bootstrap file by replacing the source Artifactory's Service ID with the target's using sed -i 's/jfrt@OLD/jfrt@NEW/g' access.backup.<TIMESAMP>.json For example,

sed -i 's/jfrt@01e719bdvrxydk0s7nw96n0kb3/jfrt@01e719b6v36b2k133v4yef14zx/g' access.bootstrap.json

Permissions in this file are tied to the service ID to allow for Access Federation, and if the swap does not occur, permissions will not be imported. 

4. Rename the access data file to access.bootstrap.json and copy to the new Artifactory instance

Artifactory 7.x: $JFROG_HOME/artifactory/var/etc/access

Artifactory 6.x: $ARTIFACTORY_HOME/access/etc

5. Import the access data

– Artifactory 7.x: Import access configuration JSON file: $JFROG_HOME/artifactory/var/etc/access/access.bootstrap.json

curl -uadmin:password -XPOST "http://localhost:8082/access/api/v1/system/backup/import"

Artifactory 6.x: Import access configuration JSON file: $ARTIFACTORY_HOME/access/etc/access.bootstrap.json

curl -uaccess-admin:password -XPOST "http://localhost:8040/access/api/v1/system/backup/import"

6. Restart Artifactory