Example 3: Back Up and Compress a Database and Then Send It Over a Network
This example shows how to:
- Configure ClearSCADA to schedule a backup.
- Compress the backup files before sending them to a remote backup server over a network.
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 user creates a Backup item called 'Server Backup' which has the following 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.
Next, the user creates a batch file called CopyZippedBackup.bat in the C:\Utilities folder. The batch file contains the following commands:
C:\Utilities\zip -r -m C:\ZippedBackups\dbBackup.zip C:\ClearSCADA\Backup
copy C:\ZippedBackups\dbBackup.zip \\RemoteServer\ClearSCADAServerABackup\dbBackup.zip
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 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 Zip program options (r is for recurse into directories and m is for deleting the original files after the compression has taken place). These 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 the Zip program has compressed them
- C:\Backup\*.* is the folder that contains the backup files that the Zip program will compress. The *.* part of the command instructs the Zip program to compress all of the backup files in the Backup folder.
- \\RemoteServer\ClearSCADAServerABackup\dbBackup.zip is the location on the remote backup server to which ClearSCADA will send (copy) the backup zip file.
The user then creates a System Command database item and sets the Command to:
C:\Utilities\CopyZippedBackup.bat
The user now makes the following changes to the Backup database item:
In the Completion Method section, the user sets the Method Object to be the System Command item and sets the Method to Execute().
The user then starts the backup manually. The backup is successful and upon completion, ClearSCADA automatically triggers the Execute method for the System Command (in accordance with the Completion Method settings configured for the Backup item). The System Command runs and compresses the backup files into a single compressed zip file. It then moves the zip file into the directory C:\ZippedBackups\dbBackup.zip and sends (copies) the zip file to the remote backup server. Finally, it deletes the original backup files.