ahaydon / Qlik-Cli-Windows

Qlik-Cli for Windows
https://adamhaydon.uk/Qlik-Cli-Windows/
GNU General Public License v2.0
110 stars 51 forks source link

Copy Qlik Server #206

Open mattiasthalen opened 1 year ago

mattiasthalen commented 1 year ago

Is there a way to use qlik-cli-windows to copy apps / streams from one server to another? We have a test server that we want to run as a copy of our production server.

Today I'm just copying the QlikShare folder and the QDF.

mountaindude commented 1 year ago

First: I am a huge fan of Qlik-Cli-Windows and use it daily in various shapes and forms. Absolutely awesome tool.

But there are also more complex use cases that I have found difficult to automate using Qlik-Cli-Windows and/or Qlik's official Qlik CLI tool, especially when it comes to interacting with the Engine API. Which is why I created Ctrl-Q, which is an open source tool that tries to automate some of those more complex scenarios.

App export and (re-)import is one such feature. One command exports apps to QVF files, another command exports complete reload task definitions to and an Excel file. A third command can then import those QVFs and task definitions into the same - or another - Sense server. The target use case is to enabled reload-tasks-as-code, i.e. define complex task chains in an easy-to-understand format (the Excel file), then create those tasks and triggers automatically. And importing QVFs too if needed.

Again, I don't mean to steal the show from Adam's tool.. but if you're lazy like me, Ctrl-Q might be useful.

By the way, a step-by-step instruction for doing the above is available in this blog post: The lazy Qlik developer #3: Bulk export/import of both apps and reload tasks.

ahaydon commented 1 year ago

Copying apps from one server to another can be done by exporting the apps and then importing them on the other server. To copy all apps and streams you would need to get a list of all streams and then use a loop or pipeline to create them on the target, the same can be done for apps using export and import commands.

mattiasthalen commented 1 year ago

I'm back at it and have a working script for exporting and then importing apps. What I'm wondering now is how I export an app and import it with it have the same ID as it has in the export system.

We have apps linking to each other by IDs, and having them remain is critical.

ahaydon commented 11 months ago

To import an app with a specific ID you need to first place the QVF in the Apps directory of the cluster share and rename it to just the ID without any file extension, then you call POST the app metadata to the /qrs/app endpoint to create the reference in the repository. These steps should be completed in the order I mention them here, otherwise you will need to restart services before you can use the app.

Assuming you read the app metadata using something like $app = Get-QlikApp 4701d35d-f836-47a0-9b06-00a7202032f6 -raw, you can use the following command to create the app in the repo.

Invoke-QlikPost /qrs/app ($app | ConvertTo-Json -Depth 10)