today's offers - xanax use in pregnancy xanax xr be abused soma internet pharmacies fedex soma without priscription fed ex phentermine parkinson drugs phentermine baclofen tramadol together ordering tramadol cod viagra find search 76k cialis pages cialis buy on line viagra for sale without a prescription buy onlinecom phentermine viagra ambien and klonopin drug interaction buy ambien overnight cheap online pharmacies valium saturday delivery valium online with no prescription or membership fioricet overnight no rx cheap fioricet without a prescription order meridia cod fedex meridia cheap fed ex delivery xanax bradycardia what does xanax look like american soma how to buy soma online without prescriptin phentermine overnight echeck c o d 375 mg phentermine rss feed cheap no prescription tramadol stop the tramadol generic prices online cialis generic cialis fedex chinese herbal viagra taking partial pill of viagra ambien and pregnancy smoking ambien cod online valium buy cheap valium without prescription no prescription fioricet with fedex fioricet without prescription in Brasilia order meridia meridia information

Posts Tagged mysql-backup

MySQL backup and restore

因為翰x要移機,所以要把db 上的資料轉出來,不過因為用mysql db < db.sql
常常會出他媽的鬼問題,很杜爛!!!
所以單純把資料dump 成 text file 會是一個比較好的方式,然後再透過mysqlimport
或是LOAD DATA INFILE
我寫了兩個小小的scripts
就是dump和 restore
有須要的人請自行服用 ::-p:
1.import_db.sh

db_dir=$1
db=$2
for file in `find $1 -type f -depth 1 | egrep txt`
do
table=`echo $file |cut -d “/” -f 5|cut -d “.” -f 1`
echo ‘import data to ‘$table’ finished ‘
/usr/local/bin/mysql -u root -p -e “load data infile ‘$file’ into table $table” $db
done

2.dump_db.sh

date=`date +%Y%m%d`
db=$1
dump_dir=$2
charset=$3
#Dump DB structure
/usr/local/bin/mysqldump -uroot -p -d $db > $dump_dir/$db.sql
# Dump Data
chown mysql:mysql $dump_dir
/usr/local/bin/mysqldump -u root -p -t –default-character-set=$charset –tab=$dump_dir $db
#tar -zcf /tmp/$db.$date.tar.gz $dump_dir

我的shell script 寫的很爛~~
別見笑~哈 :8-):

PS:剛剛在刻這篇的時後,邊和lyz講電話,一邊在shell 上工作
沒想到,他媽的不小心
rm -rf * .txt(是想刪掉所有的txt的)
結果因為多打了一個space變成我把資料全刪了
我當時在 ~ 一堆東西沒了~~~幹!!! ::S:

No Comments