Radius Manager Logs Script


#!/bin/bash

CentOS Change /var/www to /var/www/html/
TARGET=”/var/www/radiusmanager /sql_backup /etc /usr/local /var/lib/mysql”
SAVEDIR_FULL=”/backup”
sql_dir=”/sql_backup”
radpwd=”radius”
set $(date)
time=date |awk ‘{print $4}’
clear

Backup Process
start_time=date +%s
{
if [ ! -d “$SAVEDIR_FULL” ]; then
mkdir $SAVEDIR_FULL
else
fi
}

Checking if $sql_dir Folder
{
if [ ! -d “$sql_dir” ]; then
mkdir $sql_dir
else
fi
}

Creating MYSQL Dump Of Databases
echo “Main Backup started at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo “Mysql SQL export started at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
mysqldump -u radius -p$radpwd radius > $sql_dir/mysql_db_full_$6-$2-$3.sql
echo “Mysql SQL export ended at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log

Gzip MySQL Database
echo “GZIP command started at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
gzip -fv $sql_dir/mysql_db_full_$6-$2-$3.sql  >> /var/log/fullbackup.log
echo “GZIP command ended at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log

Tar Gzip (Mysql)
echo “TAR command strted at $6-$2-$3 Time $time” >> /var/log/fullbackup.log
tar cfzv $SAVEDIR_FULL/data_full_$6-$2-$3.tgz $TARGET  >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo “TAR command ended at $6-$2-$3 Time $time” >> /var/log/fullbackup.log

Deleting sql Database from $sql_dir
rm -fr $sql_dir/*
echo

MAIN Backup ended at $6-$2-$3 Time $time
echo MAIN Backup ended at $6-$2-$3 Time $time >> /var/log/fullbackup.log
end_time=date +%s
echo ” ” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log
echo ” ” >> /var/log/fullbackup.log

Print Complete Timings
echo MAIN Backup Completion Time was expr $end_time – $start_time s.
echo MAIN Backup Completion Time was expr $end_time – $start_time s. >> /var/log/fullbackup.log
echo

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s