嗨,我正在做一個數據庫從主人到奴隸copy and paste
。但是,從服務器上有一張表格,我不想被主人覆蓋。忽略mysqldump中的表?
我一直在嘗試通過cron作業運行下面的bash腳本 - 但它一直覆蓋我想忽略的從表。我究竟做錯了什麼?
#!/bin/bash
#Database login credentials - need to be changed accordingly
dbHost="localhost"
#Master (Staging)
dbMastUser="admin_site"
dbMastName="admin_site_pineapple_master"
#Slave (Live)
dbSlavUser="admin_sync"
dbSlavName="admin_site_pineapple_slave"
dbPass="ExamplePassword"
EXCLUDED_TABLES=(
forms-responses
)
IGNORED_TABLES=''
for TABLE in "${EXCLUDED_TABLES[@]}"
do :
IGNORED_TABLES+=" --ignore-table=${dbMastName}.${TABLE}"
done
#Update the database from the Master to the Slave
mysqldump -h ${dbHost} -u ${dbMastUser} -p${dbPass} ${dbMastName} ${IGNORED_TABLES} | mysql -h ${dbHost} -u ${dbSlavUser} -p${dbPass} ${dbSlavName}
你的問題是什麼? – Inian
將'localhost' var設置爲'$(localhost)'。 –
請參閱[本](http://www.tldp.org/LDP/LG/issue38/tag/6.html) –