==== client side ====
we will make a script in each server to pump date into a file. so when we check at backup server, we will check if this file was backup to backup server since it will update the date everyday.\\
below is the script contain (/root/record)
----------------- Start ---------------------------
#! /bin/sh
echo `date` > /root/assessment
then use crontab -e to run this script everyday
0 12 * * * /root/record > /dev/null 2>&1
----------------- End ---------------------------
==== backup server side ====
at the server side, i had make a folder name assessment and put the script inside.\\
below is the script contain (check_assessment)
------------------- Start -------------------------------
#! /bin/sh
echo "assessment done on `date`" > /mnt/backup/assessment/assessment_result.txt -> this is to pump the date it run the script
echo " " >> /mnt/backup/assessment/assessment_result.txt -> give an empty space
for host in `cat /mnt/backup/assessment/list` # -> this is to loop the server list
do
echo $host >> /mnt/backup/assessment/assessment_result.txt -> this is to pump the server name before it start check so we know the result is belong to which server
for n in {1..9} -> loop to check folder 01-09
do
FILE="/mnt/backup/$host/0$n/root/assessment"
if [ -f $FILE ];
then
cat $FILE >> /mnt/backup/assessment/assessment_result.txt -> if the file exist, copy the date to assessment_result.txt
else
echo "day $n didnt backup" >> /mnt/backup/assessment/assessment_result.txt -> if the file not exist, echo what day it didnt backup
fi
done
for n in {10..31} -> loop day 10-31
do
FILE="/mnt/backup/$HOST/$n/root/assessment"
if [ -f $FILE ];
then
cat $FILE >> /mnt/backup/assessment/assessment_result.txt
else
echo "day $n didnt backup" >> /mnt/backup/assessment/assessment_result.txt
fi
done
echo " " >> /mnt/backup/assessment/assessment_result.txt
done
uuencode /mnt/backup/assessment/assessment_result.txt /mnt/backup/assessment/assessment_result.txt | mail -s "[My-Backup] monthly check result" sat.support@my.offgamers.com -> this is to email the result to us as attachment
--------------------------- End -----------------------------------------
then put the server name you want this script to check into a file name list
example:-
my-domain
my-proxy
my-dns1
my-dns2
then use crontab -e to run this script every first day of the month
No comments:
Post a Comment