A data synchronization database to another database, execute the script. Demonstrated here is different from the table tab_wzc1 a database ceshiqlone of MySQL synchronized to yw library (same host) (or in different hosts, just need SSH), different databases may table structure and other factors, can not use this script, but the truth all the same, can learn from.
we mysql111.sh
#!/bin/sh
find /var/lib/mysql/wzc/wzc_sql/ -name "*.sql" -mtime +3 | xargs
rm -rf "*.sql"
time=`date +%Y%m%d`
mysqldump -uroot -p000000 ceshisqlone tab_wzc1
> /var/lib/mysql/wzc/wzc_sql/`date +%Y%m%d`_tab_wzc1.sql
sleep 3
bash sqlclient.sh
we mysqlclient.sh
#!/bin/sh
find /var/lib/mysql/wzc/wzc_sql_client/ -name "*.sql" -mtime
+3|xargs rm -rf "*.sql"
time=`date +%Y%m%d`
rsync -vzrtopgl --progress
/var/lib/mysql/wzc/wzc_sql/`date
+%Y%m%d`_tab_wzc1.sql
/var/lib/mysql/wzc/wzc_sql_client/
counts=`ls -l /var/lib/mysql/wzc/wzc_sql_client/ | grep "$time" |
awk '{print $NF}'|wc -l`
echo $counts
if [ "$counts" -eq 1 ]
then
echo sql:$counts
mysql -uroot -p000000 <<EOF
defnyddio is;
drop table tab_wzc1;
EOF
mysql -uroot -p000000 is <
/var/lib/mysql/wzc/wzc_sql_client/`date +%Y%m%d`_tab_wzc1.sql
--default-character-set=utf8
echo
OK!!!
else
echo
WRONG!!!
be
This is not a script I wrote independent, I also had other big draw God's script, even though there is an error or a problem suggested I be improved. Or have the same type of script that I provide is willing to learn.