#!/bin/bash
# fix 2006/11/24 by [email protected]
# first make the environment of ssh public key to login
set -x
export LANG=C
host_name="wwwtst"
bk_dir="/etc/ /usr/local/mysql/ /www/ /usr/local/MIDAS/ /usr/local/apache/ /usr/local/NPC3.1.2/"
bac_dir="/var/bac/$host_name"
[ -d $bac_dir ] || mkdir -p $bac_dir
cd $bac_dir
#if [ 6 = 6 ]; then
if [ `date +%w` = 6 ]; then
echo "Today is 6"
echo "delete the past files"
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
rm bk_$host_name.snapshot
echo "restart bac"
tar zcvf bk_$host_name-`date +%F`.tar.gz -g bk_$host_name.snapshot $bk_dir
else
echo "Today is not 6"
echo "if the today file exists, and exits"
[ -f bk_$host_name-`date +%F`.tar.gz ] && exit 0
echo "every day incremential bac"
tar zcvf bk_$host_name-`date +%F`.tar.gz -g bk_$host_name.snapshot $bk_dir
fi
留言