12 Replies Latest reply: Jul 10, 2014 2:52 AM by Friedrich Hofmann RSS

    Backup routine

    Friedrich Hofmann

      Hi,

       

      one issue that I have been coming back to every now and then is creating Backups on a regular basis.

      There's no question that it's necessary to do so in a professional environment.

      The issue is, we have an official routine in the company, but that is not very reliable and it's just too slow - it takes 3d to have a file re-created, and then it is not absolutely certain that it works ... so it's necessary to have something else in place, but I cannot count on the help of our official IT_department, I can't ask them "help me build something because your solution is too slow" - they (the local IT) might do it - but they cannot, it's global and they are not allowed to circumvent global standards.

       

      So - what I would like - maybe something like that is available already, I don't have the spare time to build it - is a tool that just

      - opens every app lying in a specific directory (we have a Backup directory already, I create a folder with a datestamp there once in a
         while and just copy the apps over)

      - Runs the app and deletes all the data

      - closes it

      => Thinking about it, is it not that when reloading any app, qlikView first deletes all the data before loading it again? So I could just put an EXIT command, depending on the value of a variable (with an IF THEN ENDIF) into every script. That way, I'd still have to open up and run every app, but I could do that.

      I could make the value of the variable - or the loading of the qvs file with the variable - dependent on the directory, so only the apps that are already in the backup_directory would load it.

      <=> Would that work with a  BINARY? Many of our apps have a BINARY command to load a big DataModel - we have a three-tier
               structure. The BINARY, acc. to the help_file, has to be the very first command - so how can I put that EXIT construction before
                it?

      Can anybody outthink that obstacle for me?

      Thanks a lot!

       

      Best regards,

       

      DataNibbler

        • Re: Backup routine
          Friedrich Hofmann

          Hi,

           

          well, I guess it doesn't have to be quite that complicated - once the app is in the backup_directory, I could do without a variable and just build an IF_THEN_ENDIF construct, dependent on the output of FILEDIR, with an EXIT command in it.

          <=> That leaves the issue about the BINARY LOADs. I could, of course, built just the same IF_THEN_ENDIF construct with a number of DROP commands within to get rid of all the datamodel and then EXIT. It would just be considerably more work.

           

          Best regards,

           

          DataNibbler

            • Re: Backup routine
              Friedrich Hofmann


              Hi,

               

              I think I have something - could someone tell me if this could work, please? I realized the FILEDIR() command is only good for retrieving the path to a file you just loaded, so it doesn't really help here. This might work, however.

               

              // First I set the ErrorMode to 0 so QlikView will ignore any script errors and continue anyway´

              SET ErrorMode = 0;
              // Then I load a dummy_table - a simple text_file that I would have to copy into every new backup_directory, so it
              // would not be there in the live_directories.
              Dummy:
              LOAD
                 
              AAAAAAA as Text
              FROM
              Dummy.txt
              (
              txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

              // Then I would use the NoOfRows() fct. to find out if the script just loaded anything or not
              LET v_Rows_Dummy = NoOfRows('Dummy');

              // Then I could built my IF_THEN_ENDIF construct to exit if the dummy_file was present, and thus to empty the
              // app of all data in case it is already in the backup_directory.
              IF v_Rows_Dummy >= 1 THEN
                  EXIT SCRIPT;
              ENDIF

              // Finally, I would have to reset the ErrorMode to what it was.
              SET ErrorMode = 1

               

              Best regards,

               

              DataNibbler

                • Re: Backup routine
                  Bill Markham

                  Assuming your requirement is to be able restore a qvw file [but not the data] that has somehow got broken back to a version before the breakage, then have you considered using the QV Change Control facilities ?

                   

                  [You can use it with SubVersion, that is a rock solid but a free open source software and is the de facto industry standard]

                   

                   

                  Best Regards,     Bill

                    • Re: Backup routine
                      Friedrich Hofmann

                      Hi Bill,

                       

                      yes, that is my requirement. The data is only momentaneous, but the logic in the apps has to be secured - that also serves, via the date_stamped folders, as a kind of version_control.

                      What are those Change_control_facilities you mention? I haven't heard about them before.

                      Thanks a lot!

                       

                      Best regards,

                       

                      DataNibbler

                          • Re: Backup routine
                            Friedrich Hofmann

                            Hi Bill,

                             

                            thanks a lot!

                            Maybe, though, I was not clear enough: I don't want any solution that will require me to install anything - I cannot, I don't have the ADMIN rights and I cannot ask IT "Please install a version_system, I need a backup solution that works because yours doesn't". It's true, but I cannot do that.

                             

                            => So this brings me back to my code.

                            The issue is:

                            - The code works with all the apps that don't have a BINARY LOAD in the script.

                            <=> With a BINARY, it doesn't because that has to be the very first command. I can't even place a SET command before it, can I? Well, without a >> Set ErrorMode = 0 <<, every such app will produce an error when it has been moved (copied to the backup_directory) because the relative filepath used for the BINARY LOAD is not correct - so it will generate an error_message that I have to click on, but I cannot make it stop there;

                            <=> If somehow I could use a >> SET ErrorMode=0 <<, then I could use the system_variable SCRIPTERRORCOUNT to determine whether to stop there, but I cannot.

                             

                            I will try using an absolute path for the BINARY - that way, that should run, and I can then, instead of stopping the script, drop all the tables again.

                    • Re: Backup routine
                      Rob Wunderlich

                      Once the file is on the backup directory, open the file and use File, Reduce Data, Remove all Values. Then Save.

                       

                      -Rob