#!/bin/bash
# fix 2006/11/24 by [email protected]
set -x
export LANG=C
host_name="waptst"
host_ip="192.168.2.1"
host_dir="/cygdrive/d/bk_file/"
host_bk_dir="/cygdrive/d/wifly/ /cygdrive/d/Superfate_v3/ "
bac_dir="/var/bac/$host_name"
[ -d $bac_dir ] || mkdir -p $bac_dir
cd $bac_dir
if [ `date +%w` = 6 ]; then
echo "cd $host_dir ; rm bk_$host_name-`date –date="7 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="6 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="5 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="4 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="3 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="2 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name-`date –date="1 day ago" +%F`.tar.gz" | ssh cross@$host_ip
echo "cd $host_dir ; rm bk_$host_name.snapshot" | ssh cross@$host_ip
rm bk_$host_name-`date –date="7 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="6 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="5 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="4 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="3 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="2 day ago" +%F`.tar.gz
rm bk_$host_name-`date –date="1 day ago" +%F`.tar.gz
echo "cd $host_dir ; tar zcvf bk_$host_name-`date +%F`.tar.gz -g bk_$host_name.snapshot $host_bk_dir" | ssh cross@$host_ip
scp -rp cross@$host_ip:$host_dir/bk_$host_name-`date +%F`.tar.gz $bac_dir
else
echo "cd $host_dir ; [ -f bk_$host_name-`date +%F`.tar.gz ] && exit 0" | ssh cross@$host_ip
if [ $? = 0 ]; then
:
else
echo "cd $host_dir ; tar zcvf bk_$host_name-`date +%F`.tar.gz -g bk_$host_name.snapshot $host_bk_dir" | ssh cross@$host_ip
scp -rp cross@$host_ip:$host_dir/bk_$host_name-`date +%F`.tar.gz $bac_dir
fi
fi
留言