Backing Up With Publisher

This article will describe a novel way to create a complete backup and restore system using only QlikView Publisher, complete with multiple backup versions and automated restore capabilities that can be triggered by a single button click!

The methods described in this article require that a licensed copy of QlikView Publisher be installed. To start with, it is critical to always maintain a consistent and well-planned QlikView folder structure. For the purposes of this article, I will assume that a directory structure similar to the following has been created:

I am also assuming that the backup scheme will keep the 3 latest versions of all QlikView files—this can, of course, be easily modified to keep any number of versions. The above folder structure can be as deep as you like; I am simply assuming a top-level folder structure resembling the above.

Backup

Within the Scripts folder, we will create a file called "Backup.bat" which will contain the following:

:: This will clear the contents of the 3rd version of the backup
RD "..BACKUPVersion -3" /S /Q
MD "..BACKUPVersion -3"

::Copies all files & folders from 2nd version of backup to 3rd version
XCOPY /E /Y "..BACKUPVersion -2*.*" "..BACKUPVersion -3"

:: This will clear the contents of the 2nd version of the backup
RD "..BACKUPVersion -2" /S /Q
MD "..BACKUPVersion -2"

::Copies all files & folders from 1st version of backup to 2nd version
XCOPY /E /Y "..BACKUPVersion -1*.*" "..BACKUPVersion -2"

:: This will clear the contents of the 1st version of the backup
RD "..BACKUPVersion -1" /S /Q
MD "..BACKUPVersion -1"

::Copies all files & folders from Development to 1st version
MD "..BACKUPVersion -1_Extracts"
XCOPY /E /Y ".._Extracts*.*" "..BACKUPVersion -1_Extracts"
MD "..BACKUPVersion -11_Tranformations"
XCOPY /E /Y "..1_Tranformations*.*" "..BACKUPVersion -11_Tranformations"
MD "..BACKUPVersion -12_QlikMarts"
XCOPY /E /Y "..2_QlikMarts*.*" "..BACKUPVersion -12_QlikMarts"
MD "..BACKUPVersion -13_Presentation"
XCOPY /E /Y "..3_Presentation*.*" "..BACKUPVersion -13_Presentation"
MD "..BACKUPVersion -1AccessPoint"
XCOPY /E /Y "..AccessPoint*.*" "..BACKUPVersion -1AccessPoint"
MD "..BACKUPVersion -1Resources"
XCOPY /E /Y "..Resources*.*" "..BACKUPVersion -1Resources"
MD "..BACKUPVersion -1Scripts"
XCOPY /E /Y "..Scripts*.*" "..BACKUPVersion -1Scripts"

This script will create 3 backup versions, with "Version -1" containing the last backup and "Version -3" containing the backup from 3 executions ago.

Restore from Version 1

Also within the Scripts folder, we will create a file called "RestoreV1.bat" which will contain the following:

:: This will clear the contents of the Development directories
RD ".._Extracts" /S /Q
RD "..1_Tranformations" /S /Q
RD "..2_QlikMarts" /S /Q
RD "..3_Presentation" /S /Q
RD "..AccessPoint" /S /Q
RD "..Resources" /S /Q
:: Note: the Scripts folder will not be cleared as script cannot delete itself

MD ".._Extracts"
MD "..1_Tranformations"
MD "..2_QlikMarts"
MD "..3_Presentation"
MD "..AccessPoint"
MD "..Resources"

::Copies all files & folders from 1st backup to Development
XCOPY /E /Y "..BACKUPVersion -1_Extracts*.*" ".._Extracts"
XCOPY /E /Y "..BACKUPVersion -11_Tranformations*.*" "..1_Tranformations"
XCOPY /E /Y "..BACKUPVersion -12_QlikMarts*.*" "..2_QlikMarts"
XCOPY /E /Y "..BACKUPVersion -13_Presentation*.*" "..3_Presentation"
XCOPY /E /Y "..BACKUPVersion -1AccessPoint*.*" "..AccessPoint"
XCOPY /E /Y "..BACKUPVersion -1Resources*.*" "..Resources"
XCOPY /E /Y "..BACKUPVersion -1Scripts*.*" "..Scripts"
:: Note: the Scripts folder will be overwritten if a filename conflict is found

Restore from Version 2

Within the Scripts folder, we will create a file called "RestoreV2.bat" which will contain the following:

:: This will clear the contents of the Development directories
RD ".._Extracts" /S /Q
RD "..1_Tranformations" /S /Q
RD "..2_QlikMarts" /S /Q
RD "..3_Presentation" /S /Q
RD "..AccessPoint" /S /Q
RD "..Resources" /S /Q
:: Note: the Scripts folder will not be cleared as script cannot delete itself

MD ".._Extracts"
MD "..1_Tranformations"
MD "..2_QlikMarts"
MD "..3_Presentation"
MD "..AccessPoint"
MD "..Resources"

::Copies all files & folders from 1st backup to Development
XCOPY /E /Y "..BACKUPVersion -2_Extracts*.*" ".._Extracts"
XCOPY /E /Y "..BACKUPVersion -21_Tranformations*.*" "..1_Tranformations"
XCOPY /E /Y "..BACKUPVersion -22_QlikMarts*.*" "..2_QlikMarts"
XCOPY /E /Y "..BACKUPVersion -23_Presentation*.*" "..3_Presentation"
XCOPY /E /Y "..BACKUPVersion -2AccessPoint*.*" "..AccessPoint"
XCOPY /E /Y "..BACKUPVersion -2Resources*.*" "..Resources"
XCOPY /E /Y "..BACKUPVersion -2Scripts*.*" "..Scripts"
:: Note: the Scripts folder will be overwritten if a filename conflict is found

Restore from Version 3

Within the Scripts folder, we will create a file called "RestoreV3.bat" which will contain the following:

:: This will clear the contents of the Development directories
RD ".._Extracts" /S /Q
RD "..1_Tranformations" /S /Q
RD "..2_QlikMarts" /S /Q
RD "..3_Presentation" /S /Q
RD "..AccessPoint" /S /Q
RD "..Resources" /S /Q
:: Note: the Scripts folder will not be cleared as script cannot delete itself

MD ".._Extracts"
MD "..1_Tranformations"
MD "..2_QlikMarts"
MD "..3_Presentation"
MD "..AccessPoint"
MD "..Resources"

::Copies all files & folders from 1st backup to Development
XCOPY /E /Y "..BACKUPVersion -3_Extracts*.*" ".._Extracts"
XCOPY /E /Y "..BACKUPVersion -31_Tranformations*.*" "..1_Tranformations"
XCOPY /E /Y "..BACKUPVersion -32_QlikMarts*.*" "..2_QlikMarts"
XCOPY /E /Y "..BACKUPVersion -33_Presentation*.*" "..3_Presentation"
XCOPY /E /Y "..BACKUPVersion -3AccessPoint*.*" "..AccessPoint"
XCOPY /E /Y "..BACKUPVersion -3Resources*.*" "..Resources"
XCOPY /E /Y "..BACKUPVersion -3Scripts*.*" "..Scripts"
:: Note: the Scripts folder will be overwritten if a filename conflict is found

Publisher Tasks

Open QEMC, and navigate to System >> Supporting Tasks >> External Program, and create a task reference to our Backup.bat script as follows:

Create a reference to each of the restore scripts. For example, the task reference to RestoreV1.bat would look as follows:

Task Triggers

In general, you would want to make sure that a backup runs nightly (or whenever your task chain reloads). On the other hand, the restore scripts should remain manually triggered as you clearly do not want to restore a backup every time you reload. The configuration of the restore scripts is complete. To ensure that the backup runs automatically, simple trigger the Backup task so that it runs as the first task in the reload chain. The task that was previously your first task (typically your QVD extract) would be triggered on successful completion of the Backup task.

Final Notes

The backup/restore scripts above assume that your environment is running a single task chain (i.e. that you have only 1 Production application). The batch files above can be easily modified to backup/restore only certain folders so that, e.g., if you have 2 task chains, you can create 2 versions of the above backup/restore scripts so that each version will backup only the folders relevant to that chain.

This entry was posted in Publisher and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify via email when new comments are added

Blog Home
Categories
Archives