User Tools

Site Tools


backing_up_your_data

Backing up your data

Though you might use industrial storage solutions for the WebHMI, still there is always a risk of loosing your data in some cases:

  • Just forget to make a copy of the project - this is most common case. Backup files are created on local WebHMI storage for your convinience, but it's up to you to save the latest valuable changes on your PC or other storage.
  • Occasionnally clear all collected data, e.g. when restoring your backup with unchecked “keep data” option
  • Flash drive wearing out
  • Abrupt power off during critical file operation (which you can not control) - on virtual machine or WebHMI with failed backup battery
  • Filesystem/DB operations failure, which still have a minor chances to happen. That's why RAID technologies exist.

There is only one example how to avoid the consequences of data loss.

Crontab on Linux

Here is an example of how to setup your Linux machine to automatically save files from the /log folder on the WebHMI's storage:

backup.sh
#!/bin/bash
# Create a folder ~/WEBHMI/log_backup, with the /tmp sub-folder.
LOG_DIR="$HOME/WEBHMI/log_backup"
# download the yesterday's log file to backup storage
yesterday=$(date +"%Y-%m-%d" -d yesterday)
 
cd $LOG_DIR
# because login and pass for the ftp connection are unencrypted you can 
# restrict read/write access mode to the file with chmod command)
wget --user=admin --password='webhmi' ftp://192.168.1.1/log/log-$yesterday.sqlite3
#archive to save storage space
gzip -v log-$yesterday.sqlite3

Add the script to the crontab with the parameters:

10 0 * * * /path_to_run/backup.sh

to run it every day at 00:10

Do not forget grant additional run permissions

chmod a+x /path_to_run/backup.sh

New files will only be added to ~/WEBHMI/log_backup, nothing will be deleted from this folder.