This XQuery script is designed to clone an existing server in MarkLogic. If the new server already exists, it returns the name of the new server. Otherwise, it creates a new server and returns the configuration.
- Version: 1.0
- Since: 2024-03-26
- XQuery Version: 3.1
admin
: MarkLogic Admin Module
$config
: The current configuration.$group-id
: The current group id.$server-name
: The name of the server to clone.$port
: The port of the server to clone.$new-server-name
: The name for the new server.$new-port
: The port for the new server.$servers
: All the servers.$existing-server
: The server to be cloned.$new-server
: The new server to be created.
If the new server does not exist, the script clones the existing server. Otherwise, it returns the name of the new server. The cloning process is done by copying the configuration of the existing server to the new server using the admin:appserver-copy
function. The new configuration is then saved without restarting the server using the admin:save-configuration-without-restart
function. If the new server already exists, the script simply returns the name of the new server.
Replace "existing-app-server-name-here"
with the name of the server you want to clone, and adjust the $port
, $new-server-name
, and $new-port
variables as needed. Run the script in a context where the xdmp:group() function returns the ID of the group containing the server to clone.