WII-FM

When I was young Dork starting my career I participated in Toastmasters International for 7 years. If you aren’t familiar with the organization it is a non-profit group with clubs all over the world where you meet on a regular basis to hear others share presentations, and present yourself. During one such meeting, someone I admired a lot was presenting, and I noticed their title was WII-FM. I wondered what radio station WII was on the FM dial because I had never heard of it.

The call letters were so profound I still recall them 34 years later. They stood for “What’s In It For Me.” The speaker’s message was that although you can’t find it on any radio, we all tune in to hear that station daily. Meaning we are generally self-centered and need to relate material to ourselves. While I would like to think of myself as selfless, I must admit that my first Qlik Application Automation was something to save ME time and give ME peace of mind, not to save the company a gajillion dollars.

Backups

I realize that many of you young whipper snappers have never heard the term “Backup” before so let me explain. It’s something you start doing after you’ve spent a month developing code, and you, or someone else, accidentally deletes it, or breaks it with code changes. Then you get to repeat all of your painstaking work again. Hope that never happens to you. But frankly the odds are good. So if you haven’t thought about that word before now, then pay attention. So why is this important … TO ME?

Well I have utilized about 128 different backup applications in my life, and they all have one really important trait in common. They could all automatically backup, ie preserve, my hard work that was stored on “disk drives that I could access.” Whether it be on my desktop or a server, I could have, whichever application I chose, backup my code.

As I transitioned to building Qlik Sense content in the Cloud I had to ask myself “How do I have Backup Application 97 backup my QVF files that are in my SaaS tenant?” Perhaps you have had that same thought as well. We work just as hard developing the code in the Cloud as we do on-premise. Do we not? The SaaS code we create is every bit as important as our on-premise code. Is it not?

So how do we back it up?

I hear you yapping. “You just click on the 3 dots in the lower right corner of my application and manually back it up.”

Easy-Breasy. Right?

That’s absolutely a great way for me to have piece of mind that I have a backup copy of my application locally. Now all I need is for you to remind me each and every day at specific times to do that manual step.

Oooooh and while I’m thinking about it, every now and then others in the organization will be making changes while I’m on vacation. Of course you will be there to remind them to back it up also. Right? I mean “shared development” means we developers have to share the DevOps burden together as well. Correct?

Because if we don’t all participate in the manually sharing of the “click on the 3 dots in the lower right corner of each application and manually back it up,” we just might end up modifying code and find ourselves in a real pickle. Hours/Days/Weeks of lost time.

 

Automation

What all of us SaaS developers would like is an automated way to backup our work up. Because after all … it’s about US. (I mean really ME but I have to play nice for this blog so you get to ride along for free.) The great news is that automating your backups in Qlik Cloud is super easy thanks to Qlik Application Automation, and I’m about to show you how.

Step 1

Simple create a new Application Automation and start with a blank template. Don’t you dare scroll through the list of templates and choose the backup Template. That’s too easy, and the point of this blog is to help you really understand what you are doing.

Once you have your new Application Automation created and you have a blank canvas simply locate the Qlik Cloud Services connector and choose “Export App to Base 64 encoded file” and drag it to your canvas below Start.

Notice that the description for this particular block says that it will export the application, without data, to a base64 encoded string, that we will use in another block.

Now simply click inside the “App Id” property and choose “do lookup” and choose the application you wish to backup. Don’t overthink anything yet, we will come back to this. For now all we care about is OUR application that WE are working so hard on.

Where should we back the application up to?

In my case I wanted to use GitHub. Heck it’s used to store so much code already, I might as well throw mine out there. In my case I created a project in GitHub, a PRIVATE project. Of course it defaulted to a “main” branch, but I created 7 more branches. Conveniently named 0, 1, 2, 3, 4, 5 and 6. Guess what those 7 branches are for?

If you guessed “One branch for each day of the week,” then you are a rock star coder. If you had no guess, you are probably still a rock star coder, you just haven’t proved it to me yet. 😉

My goal was to keep a rolling 7 days of backups. Thus, giving me confidence that I would never have to repeat more than 1 day of work, should I do something really silly like delete a really complicated sheet, or remove a really important section of my load script. Not that I would ever do any of those things when I got distracted, but I’ve heard from “friends” that it can be done.

Please note: There are a lot of other choices in addition to GitHub. The principles from this document will carry over to any of the SaaS storage locations you select. 

Step 2

Knowing that I wanted to backup my application and have it go to the appropriate branch, we need a way to define the day of the week in a Variable. Yes, although it is a low/no code, drag/drop environment at the end of the day, Qlik Application Automation is indeed a real development environment, so of course we can define variables. Simply choose the “Basic” section under Blocks, choose Variable and drag/drop it onto your canvas below the “Export App to Base 64 Encoded File.”

Then block will be selected by default, and in the property panel simply click in the “Variable” section to create a new variable since you will not have any yet. We will creatively call our Variable “DateTime” and use the “String” Type. Then press “Add new variable.”

Next below our variable name click the “Add Operation” and choose “Set value of DateTime” so that we can define it’s value. Then click on “f(x) Add Formula” because we will be using the Qlik Application wizard to input what we need. You know, the day # of the week.

 

Next choose “Date Functions” and chose “Date … Converts a date.” In the Edit Formula panel enter “now” for the Date, “w” for the Output format, and leave the Input formula blank.

 

How did I know to use “w” for the format? That’s easy … I cheated and clicked on the “Show more” link above the values to see what formatting was needed. There was a handy dandy “w” that was the day of the week as values 0-6.

Step 3

Our final step is to Choose the “GitHub” Connector, and then drag/drop the “Create or Update File Content” to our maker canvas below the Variable.

On the properties we will need to make the Connection to our personal or team based based GitHub location.

Then we simply input choose the “User” and “Repo” from pick lists. Since we know the name of this application we simply type the name for the “Path” value. Under “Branch” we don’t have to do anything because it will default to our “DateTime” variable from above. Notice my handy dandy, super important, highly classified MetaData I add to to GitHub about this version of my code “Automatic Backup.” and then I ensure that it has selected my “Export App to Base 64 Encoded File” for the “Base 64 File Content.”

Final Step

Our final step … quit laughing it really was as easy as 1-2-3. Our final step is to simply click on the Start block and establish the schedule. Voila you have now ensured that YOUR super duper, mission critical work is backed up on a set schedule and you never lose more than a day of work.

Can you change the output name and simply add the date/time when the backup is done to the filename you create in GitHub and store 8 million versions of your application, and schedule them to run hourly? Of course you can.

Bonus Points

[Heads up as you read the following Bonus and Gold Star items … you have to keep Security in mind. I will do a follow up post showing you how to use the Get App Information block and check the Privileges to ensure you have Export rights, and then conditionally based on those rights ether do the Export/Backup or just ignore the application and move on to those you do have permissions to.] 

For those of you who are administrators, and aren’t just single application developers … all you need to do is create a new automation for each of your 500 Qlik Cloud applications. 🤣

Just kidding. What I recommend for those of you who want “bonus points” is to choose the “List Apps” block from the “Qlik Cloud Services” connector. It will actually iterate through ALL of the applications in a specific Space. Then instead of selecting the “Application ID” from the “do lookup” property, simply choose the “id” value for the List Apps “item.” Then

Then do something similar in your “Create or Update File Content” block to use the currently iterated application name.

Gold Stars ⭐⭐⭐⭐⭐

Come on. Bonus Points wasn’t enough, some of you also want Gold Stars. As if this whole post is about YOU.

Oh wait, IT IS.

Alright, the above loop iterated through all applications in a given space but you had to choose the space. Not cool. So just go ahead and choose the “List Spaces” block under the “Qlik Cloud Services” connector and let this automation iterate for you. Now in your “List Apps” block, instead of hand picking one space, simply choose the “item id” from our List Spaces.

Now like magic, you can be a hero and have automatic backups for your SaaS development.

 

Please don’t ask me to hold your hand and show you how to change your “Create or Update File Content” GitHub block so that you can have a different project for each of your spaces. Ok, here you go.

But no more. Seriously! Y’all are already way ahead of my Qlik Application Automation video training series and I don’t want the rest of the world getting jealous.