#!/bin/sh # Webalizer usage dir && history files dir backupper. # Written by hip0 19.11.2004 # This is a free software licensed under the GPL ver 2.0 and above # check out http://www.gnu.org/licenses/gpl.txt. # dir where webalizer usage directory is located. usage_basedir=/home/customusers/default/usage; # dir where history files are stored. history_dir=/var/lib/webalizer; # Directory to store all our backups into. backup_all_dir=/home/customusers/default/b-usage; # Error log file. err_log_file=/var/log/webalizerback.log; # name prefix for the backup directories. usage_d_name="usage"; # name prefix for the history files directory. history_d_name="webalizer-history"; # baseurl baseurl="http://1c1.biz/default/b-usage"; # index file index_f='index.html'; # Get current date. cur_date=`date +%d_%m_%Y|sed -e 's/^ *//'`; # Check for basedir and backup dir existence. chk_dirs_existence () { if [ ! -d "$usage_basedir" ]; then echo "Missing $usage_basedir. Fatal Error Exiting" >>\ $err_log_file; exit 1; fi if [ ! -d "$history_dir" ]; then echo "Missing $history_dir. Fatal Error Exiting" >>\ $err_log_file; echo exit 1; fi if [ ! -d "$backup_all_dir" ]; then echo "Missing $backup_all_dir. Fatal Error Exiting" >>\ $err_log_file; exit 1; fi } # Create webalizer usage directory backup. create_backup () { if [ ! -d "$backup_all_dir/$usage_name$cur_date" ]; then mkdir -p "$backup_all_dir/$usage_d_name$cur_date"; fi cp -rpf $usage_basedir $backup_all_dir/$usage_d_name$cur_date; if [ ! -d "$backup_all_dir/$history_d_name$cur_date" ]; then mkdir -p "$backup_all_dir/$history_d_name$cur_date"; fi cp -rpf $history_dir $backup_all_dir/$history_d_name$cur_date; } # Generates index.html with links to all the usage backups. links_html_gener () { cat /dev/null > $backup_all_dir/$index_f; echo '' >> $backup_all_dir/$index_f; echo '
' >> $backup_all_dir/$index_f; echo "