Example 2: Back up a Database and Compress the Backup After Completion
This example shows how to configure ClearSCADA to schedule a backup and then compress the backup files once the backup is complete.
NOTE: The file names and file path names in the example below are for illustrative purposes only. You will need to use file names and paths that are appropriate for your system.
The backup will run on your Main server. You need to set up the folders that you refer to in the backup settings on all the servers that might become a Main server.
Example:
In ViewX, a Backup item is created. It is named 'Server Backup' and is configured to have these settings:
- In Service: Enabled
- Severity: High
- Default Parent Directory: C:\ClearSCADA\
- Default Destination: Backup
- Trip Sequence Time: NOW
- Database: Enabled
- Historic Data: Enabled, Start Offset: Hour -2 Months, End Offset: Hour
- Event Journal: Disabled.
- Configuration Changes: Disabled.
A System Command database item is created and configured to have its Command set to:
C:\Utilities\zip -r -m C:\ZippedBackups\dbBackup.zip C:\ClearSCADA\Backup\*.*
Where:
- The 'C:\Utilities\zip' part of the command instructs ClearSCADA to run the file compression program in C:Utilities (in the case of this example, this is Info-Zip's Zip program, which is freely available from www.info-zip.org). This is a third-party program that ClearSCADA uses to compress the backup files. You could replace this program with another file compression program of your choice if you want.
- -r and -m are options available with the Zip program (r is for recurse into directories and m is for deleting the original files after the compression has taken place). These Zip program options may not be available in other file compression programs.
- C:\ZippedBackups\dbBackup.zip is the directory and zip file that will contain the backup files after they have been compressed
C:\ClearSCADA\Backup\*.*
is the location of the backup files that are to be compressed, with *.* used to include all files in that location.
The Backup database item is reconfigured. In the Completion Method section, the Method Object is set to be the System Command item and the Method is set to Execute().
A user triggers the backup manually. The backup is successful and upon completion, the Execute method for the System Command is triggered automatically (in accordance with the Completion Method settings configured for the Backup item).The System Command runs and compresses the backup files, before moving the zip file into a different directory (C:\ZippedBackups\dbBackup.zip), and then deleting the original backup files.