User Tools

Site Tools


backing_up_your_data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
backing_up_your_data [2021/09/28 12:55] – bash to sh atolstovbacking_up_your_data [2022/08/12 14:23] atolstov
Line 3: Line 3:
  
  
-{{ ::data-backup.png?nolink&60|}}+{{ network:data-backup.png?nolink&60|}}
 <WRAP center round important 80%> <WRAP center round important 80%>
  
Line 22: Line 22:
  
  
-<code bash>+<code bash backup.sh>
 #!/bin/bash #!/bin/bash
-# Create a folder ~/WEBHMI/log_backup, with the /tmp sub-folder. +# Create a folder ~/webhmi-log-cron, with the /tmp sub-folder. 
-LOG_DIR="$HOME/WEBHMI/log_backup"+LOG_DIR="$HOME/webhmi-log-cron" 
 +cd $LOG_DIR/tmp
 # download the yesterday's log file to backup storage # download the yesterday's log file to backup storage
 yesterday=$(date +"%Y-%m-%d" -d yesterday) yesterday=$(date +"%Y-%m-%d" -d yesterday)
 + 
 +
  
-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='webhmi' ftp://192.168.1.1/log/log-$yesterday.sqlite3+wget --user=admin --password='webhmi' ftp://192.168.68.3/log/log-$yesterday.sqlite3
 #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/tmp/*  
 </code> </code>
 +
 +<WRAP center round tip 60%>
 +Do not forget grant additional run permissions
 +</WRAP>
 +  chmod u+x /path_to_run/backup.sh
 +
  
 Add the script to the //crontab// with the parameters: Add the script to the //crontab// with the parameters:
Line 41: Line 54:
 to run it every day at 00:10  to run it every day at 00:10 
  
-<WRAP center round tip 60%> 
-Do not forget grant additional run permissions 
-</WRAP> 
-  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. New files will only be added to ~/WEBHMI/log_backup, nothing will be deleted from this folder.
backing_up_your_data.txt · Last modified: 2023/05/02 10:43 by atolstov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki