#!/bin/bash # Create a folder ~/webhmi-logs-backup, with the /tmp sub-folder. HOST=192.168.1.1 LOG_DIR="$HOME/webhmi-logs-backup" cd $LOG_DIR/tmp # download yesterday's log file to backup storage yesterday=$(date +"%Y-%m-%d" -d yesterday) # 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://$HOST/log/log-$yesterday.sqlite3 #archive to save storage space 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/*