Everything in the following blog post pertains to API Connect version 10.0.5.5+. Some introductory information on using the Portal Admin CLI can be found at https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=cli-getting-started-portal-commands if you aren’t familiar with the process.
PLEASE BACKUP YOUR DEVELOPER PORTAL ANYTIME YOU USE THESE COMMANDS AS THEY CAN INCLUDE LOSS OF DATA
Introduction
These new Portal Admin CLI commands concerning site import and export are essentially a wrapper for 4 existing Portal Admin CLI commands; custom-module, custom-theme, site-config, content.
To set the scene of when these commands can be used, imagine you have just spent the time crafting the perfect Developer Portal and now want to replicate all those changes onto to your production Developer Portal. In the past it would have been painstaking as you would need to replicate all those changes by hand. Now you can use the new site promotion commands to take all the necessary genetic make-up of one site and import into the next. The fun doesn’t stop there though, you can use these commands in a CI/CD process to export and import any future changes you make on your dev site that you would like to promote to production.
In this tutorial we will export our dev site’s genetic make-up and import it into our prod site. One thing you will have to note is that when importing a site export, the export has to have been generated from a site that is on the same version you are importing too.
Export Site
-
Log in to the CLI
apic login --realm provider/default-idp-2 --username <username> --password <password> --server <management-platform-api>
-
Export the dev site
apic --mode portaladmin -s <management-platform-api> -o <org> -c <dev-catalog> site:create-export
The tgz generated could contain up to 4 tgz inside. site-content.tgz, site-config.tgz, site-custom-themes.tgz and site-custom-modules.tgz. The last two are not required to be in tgz as we understand not all Developer Portals will use custom themes or modules. The first two tgzs (site-content.tgz and site-config.tgz) must be contained in the export for it considered to be a valid export which will need to be kept in mind when importing.
Import Site
-
Log in to the CLI
apic login --realm provider/default-idp-2 --username <username> --password <password> --server <management-platform-api>
-
Import to Prod site
apic --mode portaladmin -s <management-platform-api> -o <org> -c <prod-catalog> site:create-import site_createExport-20231013153305.tgz
As shown in the image above you get back a nice detailed response of everything its importing at each step of the import process. The configuration import step doesn’t have any verbose information due to the way configuration import works in Drupal.
Conclusion
It’s as simple as that, running two command to copy the look and feel of one site to another. As one can imagine the import process does take some time so don’t be alarmed if you think its not doing anything. In the Portal Admin CLI the site:import command polls for a total of 15 minutes at 10 second intervals. If you find your imports are taking longer and the command times out you can always retrieve the task status by running site:get-import-status.
Further Reading:
Here are some links to the how the individuals commands are ran, that are incorporated in this site promotion process.
Custom-module
https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=commands-using-custom-module
Custom-theme
https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=commands-using-custom-theme
Site-config
https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=commands-using-site-config
Content
Portal CLI Admin Content Commands
#APIConnect#portal#developerportal#portalcli#drupal