Update Script (for Linux)
Following article describes linux update script (written in BASH) which can backup, restore and update Historian server application. Same procedure can be done manually using information from this documentation.
Note: Update script must be run using root privileges (under root account or using sudo).
Terminology
- application backup - archive containing Historian application (usually contains subfolder like assets, bin, Content, etc.), but excluding application data folder (App_Data)
- data backup - archive containing solely App_Data folder from application - usually contains configuration files, user profiles, calculations and signal documentations.
- application update file - just an application backup taken from one server and uploaded to other server
File naming convention
All backups and update files conform to specific naming convention. Application backups and updates start with a pa_, while data backup start with a pd_. This prefix is followed by application name (usually poweranalyzer if there is only one application on the host) and the creation timestamp (YYYYMMDD-HHmmSS format). At the end there are last 3 chars of the md5sum command and an extension .tgz. Before extraction, the checksum is validated and operation aborted if the validation fails.
Inline help
sudo ./pa-update.sh --help
Listing available applications
Lists known Historian installations on current host.
Technically: The script looks into the /var/www folder and examines every subfolder. Every subfolder is then searched inside /etc/apache2/sites-enabled/*.conf files. If match is found, application URL is identified (extracting VirtualHost IP and PORT configuration). ADMINKEY is extracted from /var/www/applicationFolder/App_Data/instance.xml file. Every application URL is than tested using wget utility to retrieve Historian version code (/apiv1/info?adminKey=ADMINKEY). The version test may fail for example if the app is not running, etc. Exact state of application should be checked manually!
sudo ./pa-update.sh --list-apps
Update version
This command performs automatic update of specified Historian application on server. It includes old application backup&deletion, unpacking new application, permission settings and quick self-test.
Technically: This command just uses other subcommands to perform the whole update process.
- Backups the specified application
- Deletes current application (leaving data folder in place
- Restores application from specified update file
- Restarts apache2 service
- Checks if application is running (may not suceed if the application is starting too long because eg. data indexing, etc.)
sudo ./pa-update.sh --update poweranalyzer pa_poweranalyzer_12345_678.tgz
Note: First parameter - poweranalyzer - in the previous sample is the name of the application to be updated. This name is used almost everywhere, excl. situations where multiple application instances are running on same machine. Name of the application can be obtained using the --list-apps command. Second parameter specified the name of the update package which should be placed in the same folder as the update script (usually /var/www).
Listing application backups
Lists application backup files stored on current host.
Technically: Application backups are just normal TGZ archives stored in /var/www/pa-backup/apps folder. This command lists these files.
sudo ./pa-update.sh --list-app-backups
Listing data backups
Lists data backup files stored on current host.
Technically: Data backups are just normal TGZ archives stored in /var/www/pa-backup/data folder. This command lists these files.
sudo ./pa-update.sh --list-data-backups
Backup application
Backups specified application.
Technically: Application backups are just normal TGZ archives stored in /var/www/pa-backup/apps folder. This command takes application (usually folder /var/www/poweranalyzer/) and archives it under /var/www/pa-backup/apps folder.
sudo ./pa-update.sh --backup-app poweranalyzer
Backup data
Backups specified application data.
Technically: Data backups are just normal TGZ archives stored in /var/www/pa-backup/data folder. This command takes application data folder (usually /var/www/poweranalyzer/App_Data) and archives it under /var/www/pa-backup/data folder.
sudo ./pa-update.sh --backup-data poweranalyzer
Remove backup files
Deletes stored backup (both application and data) files. Warning: This command requires no confirmation.
Technically: Backup files are normal .TGZ files stored in /var/www/pa-backup folder. This command erases them.
sudo ./pa-update.sh --backup-clean
Delete application files
Delete application files for some instance of the application (usually folder /var/www/poweranalyzer), leaving application data (usually folder /var/www/poweranalyzer/App_Data) in place.
sudo ./pa-update.sh --delete-app poweranalyzer
Delete data files
Delete data files for some instance of the application (usually folder /var/www/poweranalyzer/App_Data), leaving application files (usually folder /var/www/poweranalyzer) in place.
sudo ./pa-update.sh --delete-data poweranalyzer
Restore app backup
Restores application backup. Application name is specified as the first argument (usually poweranalyzer), application backup is the second argument (list of available application backups can seen using --list-app-backups argument). It is recommended to delete old application files prior using this command (using switch --delete-app).
Technically: Backup files are normal .TGZ files stored in /var/www/pa-backup/apps folder. This command extracts the backup file into particular application folder (usually /var/www/poweranalyzer).
sudo ./pa-update.sh --restore-app poweranalyzer pa_poweranalyzer_12345_678.tgz
Restore data backup
Restores application backup. Application name is specified as the first argument (usually poweranalyzer), application backup is the second argument (list of available application backups can seen using --list-app-backups argument). It is recommended to delete old application data prior using this command (using switch --delete-data).
Technically: Backup files are normal .TGZ files stored in /var/www/pa-backup/data folder. This command extracts the backup file into particular application data folder (usually /var/www/poweranalyzer/App_Data).
sudo ./pa-update.sh --restore-data poweranalyzer pd_poweranalyzer_12345_678.tgz