backing_up_your_data
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
backing_up_your_data [2021/11/17 09:54] – [Crontab on Linux] atolstov | backing_up_your_data [2023/05/02 10:43] – atolstov | ||
---|---|---|---|
Line 3: | Line 3: | ||
- | {{ :: | + | {{ network: |
<WRAP center round important 80%> | <WRAP center round important 80%> | ||
- | Though you might use industrial storage solutions for the WebHMI, still __there is always a risk of loosing | + | Though you might use industrial storage solutions for the WebHMI, still __there is always a risk of losing |
- | *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. | + | *Just forget to make a copy of the project - this is the most common case. Backup files are created on local WebHMI storage for your convenience, but it's up to you to save the latest valuable changes on your PC or other storage. |
- | *Occasionnally | + | *Occasionally |
*Flash drive wearing out | *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 | + | *Abrupt power off during critical file operation (which you can not control) - on a virtual machine or WebHMI with a failed backup battery |
- | *Filesystem/ | + | *Filesystem/ |
</ | </ | ||
+ | There is only one example of how to **avoid the consequences of data loss** considered here. Using shell script via crontab utility. | ||
- | 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 ''/ | ||
+ | ===== Download all present logs once ===== | ||
+ | At the very start, it is a good idea to download all the data. | ||
+ | <code bash backup-ALL.sh> | ||
+ | #!/bin/bash | ||
+ | # Create a folder ~/ | ||
+ | HOST=192.168.1.1 | ||
+ | LOG_DIR=" | ||
+ | mkdir -p $LOG_DIR/ | ||
+ | cd $LOG_DIR/ | ||
+ | # Get all logs (including today, which is, however, obviously partial) | ||
+ | wget --user=admin --password=webhmi -nH --cut-dirs=1 " | ||
+ | # Archive to save storage space | ||
+ | gzip -f -v * | ||
+ | # Copy out of tmp .gz file and do not overwrite if destination filename already exists | ||
+ | cp -r --backup=t log-*.sqlite3.gz ../. | ||
+ | # Clear tmp folder | ||
+ | rm $LOG_DIR/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Crontab on Linux ===== | ||
+ | Here is an example of how to set up your Linux machine to automatically save files from the ''/ | ||
<code bash backup.sh> | <code bash backup.sh> | ||
#!/bin/bash | #!/bin/bash | ||
- | # Create a folder ~/WEBHMI/ | + | # Create a folder ~/webhmi-logs-backup, with the /tmp sub-folder. |
- | LOG_DIR=" | + | HOST=192.168.1.1 |
- | # download | + | LOG_DIR=" |
+ | cd $LOG_DIR/ | ||
+ | # download yesterday' | ||
yesterday=$(date +" | yesterday=$(date +" | ||
+ | |||
- | cd $LOG_DIR | + | |
- | # because login and pass for the ftp connection are unencrypted you can | + | # because login and pass for the FTP connection are unencrypted you can |
# restrict read/write access mode to the file with chmod command) | # restrict read/write access mode to the file with chmod command) | ||
- | wget --user=admin --password=' | + | wget --user=admin --password=' |
#archive to save storage space | #archive to save storage space | ||
- | gzip -v log-$yesterday.sqlite3 | + | gzip -f -v log-$yesterday.sqlite3 |
+ | # Copy out of tmp .gz file and do not overwrite if destination filename already exists | ||
+ | cp -r --backup=t log-$yesterday.sqlite3.gz ../. | ||
+ | # Clear tmp folder | ||
+ | rm $LOG_DIR/ | ||
</ | </ | ||
<WRAP center round tip 60%> | <WRAP center round tip 60%> | ||
- | Do not forget grant additional run permissions | + | Do not forget |
</ | </ | ||
chmod u+x / | chmod u+x / |
backing_up_your_data.txt · Last modified: 2023/05/02 10:43 by atolstov