open 209.86.18.210 60017
user $ftpUser $ftpPWD
bin
#passive
mkdir $date0
cd $date0
put mysql-$IP-$date.tar
bye
EOF
cat tab_bak.sh_bak
#!/bin/sh
IP=master-table-20.221.158.38
scriptsDir=`pwd`
dataDir=/data/mysql
tmpBackupDir=/tmp/mysqlbackup
backupDir=/backup/mysql
ftpUser=femart_db_bak
ftpPWD='d@sd2D$fsd:8G2l'
mysqlPWD='mysql_password'
if [[ -e $tmpBackupDir ]]; then
rm -rf $tmpBackupDir/*
else
mkdir $tmpBackupDir
fi
file=`ls -t /backup/mysql|grep master-table |sed -n '20,$p'`
for i in $file;do
rm -rf /backup/mysql/$i
done
if [[ ! -e $backupDir ]];then
mkdir -p $backupDir
fi
echo "`date +%Y%m%d%H%M` mysqlback start" >>"$backupDir"/`date +%Y%m%d`.log
dbname=`find "/data/mysql" -type d|sed -e "s#/data/mysql/##"|sed -e "s#/data/mysql##"|sed -e "s/^test$//"|grep -v "mysql"|grep -v femart_20111115 |grep -v proftpd |grep -v febay_sphinx |grep -v febay_guidang |grep -v febay |grep -v beifen_femart |grep -v beifen_febay |grep -v beifen2_femart |grep -v 2010|grep -v 2011|sed -e "/^$/d"`
#for databases in $dbname; do
#if [[ $databases == "" ]]; then
#continue
#else
#errfile="$backupDir"/`date +%Y%m%d`.err
#echo "dumping $databases">>$errfile
#/usr/local/mysql/bin/mysqldump -uroot -p$mysqlPWD -B --single-transaction $databases >"$tmpBackupDir"/"$databases".sql 2>>$errfile
#fi
#done
for table in sdb_orders sdb_order_items sdb_order_log sdb_operators sdb_members ; do
if [[ $table == "" ]] ; then
continue
else
errfile="$backupDir"/`date +%Y%m%d`.err
echo "dumping $databases">>$errfile
/usr/local/mysql/bin/mysqldump -uroot -p$mysqlPWD femart $table >"$tmpBackupDir"/"femart_$table".sql 2>>$errfile
fi
done
echo "`date +%Y%m%d%H%M` mysqlback stop,start compress!" >>"$backupDir"/`date +%Y%m%d`.log
date=`date +%Y%m%d-%H%M`
cd $tmpBackupDir
tar czf $backupDir/mysql-$IP-$date.tar.gz ./
echo "`date +%Y%m%d%H%M` mysqlback end!" >>"$backupDir"/`date +%Y%m%d`.log
#End
date0=`date +%Y%m%d`
cd $backupDir
/usr/bin/ftp -n<
open 192.168.0.124 60017
user $ftpUser $ftpPWD
bin
#passive
mkdir $date0
cd $date0
put mysql-$IP-$date.tar.gz
bye
EOF
[root@china_blog sql]# cat /root/yuanbloger_bak/back4_yuanbloger.sh
#some variable
BaseDir="/root/yuanbloger_bak/sql"
BaseName="yuanbloger_"
LatestSql=$BaseDir"/yuanbloger_latest.sql"
Now=$(date +%Y%m%d%H%M%S)
NowD=$(date +%Y%m%d)
NowH=$(date +%Y%m%d%H0000)
DailyDir=$BaseName$NowD
HourlySql=$BaseDir"/"$BaseName"sql_"$NowH".sql"
LoggerFile=$BaseDir"/sj_logger.log"
#dump sql file
echo $Now" started!">>$LoggerFile
mysqldump --opt wwwyuanblogercom -h localhost -uwwwyuanblogercom -pwwwyuanblogercom --add-drop-table --lock-tables=0 >$HourlySql
8># cat /data/backup/mysql_backup
#!/bin/bash
DBUser=backup
DBPasswd=7dgfdssf
DBName=`echo "select SCHEMA_NAME from information_schema.SCHEMATA where schema_name not in ('information_schema','mysql','test');" | mysql -u$DBUser -p$DBPasswd -S /tmp/mysql.sock`
BackupPath=/data/backup/
LogFile=/data/backup/log/mysql_backup.log
pushd $BackupPath >> $LogFile
NewFile=$(date +%Y%m%d).tgz
DumpFile2=*.sql
OldFile=$(date +%Y%m%d --date='7 days ago').tgz
echo $OldFile
echo "-------------------------------------------" >> $LogFile
echo $(date +"%Y-%m-%d %H:%M:%S") >> $LogFile
echo "--------------------------" >> $LogFile
#Delete Old File
if [ -f $OldFile ]
then
rm -f $OldFile >> $LogFile 2>&1
echo "[$OldFile]Delete Old File Success!" >> $LogFile
else
echo "[$OldFile]No Old Backup File!" >> $LogFile
fi
if [ -f $NewFile ]
then
echo "[$NewFile]The Backup File is exists,Can't Backup!" >> $LogFile
else
for item in $DBName
do
DumpFile=$item".sql"
if [ -z $DBPasswd ]
then
mysqldump -S /tmp/mysql.sock -u$DBUser -p$DBPasswd -B --single-transaction --default-character-set=utf8 $item > $DumpFile
else
mysqldump -S /tmp/mysql.sock -u$DBUser -p$DBPasswd -B --single-transaction --default-character-set=utf8 $item > $DumpFile
fi
done
/bin/tar czvf $NewFile $DumpFile2 >> $LogFile 2>&1
echo "[$NewFile]Backup Success!" >> $LogFile
/bin/rm -f *.sql
fi
echo "-------------------------------------------" >> $LogFile
popd
cat dbbak.sh
#!/bin/sh
IP=monitor-220.231.158.124
scriptsDir=`pwd`
dataDir=/data/mysql
tmpBackupDir=/tmp/mysqlbackup
backupDir=/backup/mysql
#ftpUser=silidbbak
#ftpPWD='falk*k2lLjdk752KDSLD'
mysqlPWD='123456'
if [[ -e $tmpBackupDir ]]; then
rm -rf $tmpBackupDir/*
else
mkdir $tmpBackupDir
fi
file=`ls -t /backup/mysql|grep tar|sed -n '5,$p'`
for i in $file;do
rm -rf /backup/mysql/$i
done
if [[ ! -e $backupDir ]];then
mkdir -p $backupDir
fi
echo "`date +%Y%m%d%H%M` mysqlback start" >>"$backupDir"/`date +%Y%m%d`.log
dbname=`find "/data/mysql" -type d|sed -e "s#/data/mysql/##"|sed -e "s#/data/mysql##"|sed -e "s/^test$//"|grep -v 2011|grep -v 2012|sed -e "/^$/d"`
for databases in $dbname; do
if [[ $databases == "" ]]; then
continue
else
errfile="$backupDir"/`date +%Y%m%d`.err
echo "dumping $databases">>$errfile
/usr/local/mysql/bin/mysqldump -uroot -p$mysqlPWD $databases >"$tmpBackupDir"/"$databases".sql 2>>$errfile
fi
done
echo "`date +%Y%m%d%H%M` mysqlback stop,start compress!" >>"$backupDir"/`date +%Y%m%d`.log
date=`date +%Y%m%d-%H%M`
cd $tmpBackupDir
tar czf $backupDir/mysql-$IP-$date.tar.gz ./
echo "`date +%Y%m%d%H%M` mysqlback end!" >>"$backupDir"/`date +%Y%m%d`.log
#End
#date0=`date +%Y%m%d`
#cd $backupDir
#/usr/bin/ftp -n<
#open 10.20.137.138 21
#user $ftpUser $ftpPWD
#bin
#passive
#mkdir $date0
#cd $date0
#put mysql-$IP-$date.tar.gz
#bye
#EOF
阅读(1198) | 评论(0) | 转发(0) |