器量大者,福泽必厚
全部博文(587)
分类: LINUX
2011-11-28 11:05:35
香港的机制修改了!
备份下原来的脚本
只为自己工作只用!
#!/bin/bash
HOST_IP=`/sbin/ifconfig eth0 | grep *.*.* |awk '{print $2}'|awk -F: '{print $2}'`
Target_Path=/usr/Backup_web_mount_point
Vhost_date=`date +%Y%m%d`
Backup_date=`date +%y%m`
Delete_date=`date --date "7 days ago" +"%Y%m%d"`
vhost_dir1=/usr/local/xncenter/confcenter
vhost_dir2=/usr/local/xncenter/confcenter/scripts/backup_web_scripts
mkdir -p $Target_Path/$HOST_IP-alldomain/$Vhost_date
rm -fr $Target_Path/$HOST_IP-alldomain/${Delete_date}
Backup_full_path=$Target_Path/$HOST_IP-alldomain/$Vhost_date
sleep 10
#
##############################
###Find vhost.conf File domain name.
#
if [ -e domain_names.txt ];then
rm -rf domain_names.txt
fi
#
cat $vhost_dir1/vhost.conf | grep 'ServerName www'| sort -nr | uniq -c | sort -nr> $vhost_dir2/domain_names.txt
Domain_Capture=`awk '{print $3}' $vhost_dir2/domain_names.txt`
#
#
if [ -e full_domain_name.txt ];then
rm -rf full_domain_name.txt
fi
for i in ${Domain_Capture}
do
#sleep 1
cd $vhost_dir2
echo $i >> full_domain_name.txt
done
#
rm -rf domain_names.txt
##
##
Ip_only=`echo $HOST_IP |cut -d . -f4`
if [ -e world_domain_list-$Ip_only.txt ];then
rm -rf world_domain_list-$Ip_only.txt
fi
#
SUB=`cat full_domain_name.txt`
for f in ${SUB}
do
expr "$f" : '[^\.]*\.\(.*\)' >> world_domain_list-$Ip_only.txt
done
rm -rf full_domain_name.txt
sleep 10
#
#
#####
################################
##################
##Compressed backup of the corresponding domain name website
##
#
cd $vhost_dir2
domain_list=`cat $vhost_dir2/world_domain_list-$Ip_only.txt`
#
#
for var in ${domain_list}
do
sleep 1
a=`echo $var|cut -c 1`
b=`echo $var|cut -c 2`
c=`echo $var|cut -c 3`
cd /usr/vhome/${a}/${b}/${c}/${var}
#Backup data
tar -zcvf $Backup_full_path/$HOST_IP-${var}-$Vhost_date.tar.gz ./*
done
cd /usr/local/xncenter
tar -zcvf $Backup_full_path/confcenter-${HOST_IP}-${Vhost_date}.tar.gz ./confcenter
ftp -n 10.7.2.6 >error 2>&1 <
bin
prompt
cd /*.*.*.*/web
mkdir $Vhost_date
cd /*.*.*.*/web/$Vhost_date
lcd $Backup_full_path
mput *
bye
EOC