#!/bin/sh
##############################################
# #
# #
# tar the all backup data and saved #
# in backuptar directory #
# #
##############################################
function pid_check(){
###check the rsync scrpits have finished
count=0
for i in 1 2 3
do
if [ -f "/tmp/rsync_backup.pid" ];then
sleep 60
((count++))
fi
done
if [ $count -eq 3 ];then
echo -e "Rsync the backup files maybe have problesm,the cn_backup.pid exits." | mail -s "Tarball failure,can not continue `hostnae -i`" $Mail
exit 43
fi
}
function pid_lock(){
if [ -f "$pid_file" ];then
backup_tar_pid=`cat $pid_file`
echo -e "Tarball failure for Backup Server: \n
PID: $backup_tar_pid
DATE: $DATE
Script: $0 " | mail -s "Tarball failure for Backup Server `hostname -i`" $Mail
echo "Tarball failure" >> /home/opsuser/backup_log/${LogName}_$DATE.log
exit 44
else
echo $$ > $pid_file
fi
}
function pid_free(){
rm $pid_file
if [ -f "$pid_file" ];then
echo "$pid_file exist, please check the pid file" >> /home/opsuser/backup_log/${LogName}_$DATE.log
fi
}
thread=8
for ((i=0;i < $thread;i++))
do
echo
done >& 6
for i in $BACKUP_DIR
do
read -u6
{
sleep 3
Name=`echo ${i##*/}`
cd $i
if [ $i = "/data/config_bak/httpd_201" ]
then
tar zcf ${Name}_${DATE}.tgz backup --exclude downloads
else
tar zcf ${Name}_${DATE}.tgz backup
fi
#ls -l ${Name}_${DATE}.tgz #It is using for test