The JFrog CLI offers a "replication-create" action , which requires a Replication Template file. In BASH, you can create these template files by using the repositories.list file and some clever processing tricks.
A] First, configure the JFrog CLI with both "source" and "target" Artifactories:
B] Generate the Replication template configuration files. The loop below will read each line of the "repositories.list" file and create a template file based on the key:
[Expected JSON File Contents]

After the loop finishes, please check the resulting files. They should all look like the above example image. It's important to double check the templates before we mass-deploy them to the Source to prevent misconfigured settings from being deployed into the Old Artifactory.
C] Run the "replication-create" CLI command on each of the JSON files, this script will do this for you:
This will push each template to the Source Artifactory, and at the end all Artifactory's Local Repositories will be configured to push to the Target:


A] First, configure the JFrog CLI with both "source" and "target" Artifactories:
jfrog config add source #Define the DR Source Artifactory jfrog config add target #Define the DR Target
B] Generate the Replication template configuration files. The loop below will read each line of the "repositories.list" file and create a template file based on the key:
# The JFrog CLI uses the name "target" and fills in the right URL when replication is configured cat repositories.list | while read line do #Variable setup #Get the repository key, remove "key": from the JSON REPO=$(echo $line | cut -d ':' -f 2) REPO_FILENAME=$(echo ${REPO%??} | cut -c 2-) #Get a good looking filename #Insert the static default parameters echo '{ "enabled": "true","cronExp":"0 0 12 * * ?",' > $REPO_FILENAME-template.json #Insert the repository Key echo '"repoKey": '$REPO >> $REPO_FILENAME-template.json #Insert the remaining parameters, note we're replicating to the same repository name echo '"serverId": "target", "targetRepoKey": '$REPO' "enableEventReplication":"true" }' >> $REPO_FILENAME-template.json done
[Expected JSON File Contents]
After the loop finishes, please check the resulting files. They should all look like the above example image. It's important to double check the templates before we mass-deploy them to the Source to prevent misconfigured settings from being deployed into the Old Artifactory.
C] Run the "replication-create" CLI command on each of the JSON files, this script will do this for you:
jfrog config use source ls | while read line do echo "jfrog rt replication-create $line" jfrog rt replication-create $line done
This will push each template to the Source Artifactory, and at the end all Artifactory's Local Repositories will be configured to push to the Target: