<pre name="code" class="sql">. ~/.bash_profile
TODAY_DIR=`date +%Y%m%d`;
old_dir=`date +%Y%m%d --date='7 days ago'`;
cd /data02/database_backup/
if [ -f $old_dir ]; then
rm -rf $old_dir
rm -rf $old_dir.tar.gz
fi
if [ ! -d $TODAY_DIR ]; then
mkdir -p $TODAY_DIR/quartz
mkdir -p $TODAY_DIR/zjzc
fi
mysqldump -uroot -p'xx' -R --single-transaction --master-data=2 quartz>$TODAY_DIR/quartz/quartz_${TODAY_DIR}.sql
if [ $? -eq "0" ]
then
smail.pl quartz
fi
mysqldump -uroot -p'xx' -R --single-transaction --master-data=2 zjzc>$TODAY_DIR/zjzc/zjzc_${TODAY_DIR}.sql
if [ $? -eq "0" ]
then
smail.pl zjzc
fi
cd /data02/database_backup/
tar -czvf ${TODAY_DIR}.tar.gz ${TODAY_DIR}
scp ${TODAY_DIR}.tar.gz root@1.1.57.101:/data02/database_backup