标签:
for((i=91;i>=1;i--)); do dt=`date +‘%Y%m%d‘ -d"-${i} days"`; if [ "$dt" = "20150309" ]; then break; fi SQL=‘SELECT `id` FROM `l_pro_index_‘${dt}‘` ORDER BY `id` ASC LIMIT 1;‘ first_id=`echo ${SQL} | mysql -hhost -uuser -ppassword -N database2` mysqldump -hhost -uuser2 -ppassword database l_pro_index_${dt} -w "id<${first_id}" --skip-lock-tables=true --no-create-info --quick --complete-insert --add-locks=false --disable-keys=false --extended-insert=false > l_pro_index_${dt}.sql mysql -hhost -uuser -ppassword -A database2 < ./l_pro_index_${dt}.sql done
标签:
原文地址:http://my.oschina.net/jackin/blog/397515