Backup tables of mysql server and import to the other server
IPFS
The usage here is to import gcp sql to aliyun
First backup with mysqldump on the gcp server, then use sshpass (to be installed separately) to specify the password to do scp to the aliyun server
$ sudo more /var/opt/www/sqldump/dump.sh #!/bin/sh mysqldump --set-gtid-purged=OFF -h sql_server_1_address -u USERNAME -pPASSWORD dbname tablename1 > /var/opt/sqldump/tablename1.sql mysqldump --set-gtid-purged=OFF -h sql_server_1_address -u USERNAME -pPASSWORD dbname tablename2 > /var/opt/sqldump/tablename2.sql sshpass -p "PASSWORD" scp /var/opt/sqldump/*.sql root@server_2_address:/var/opt/sqlimport/ $ sudo crontab -l */10 * * * * sh /var/opt/www/sqldump/dump.sh
If mysqldump wants to add conditional filtering, you can use something like this
mysqldump --set-gtid-purged=OFF -h sql_server_1_address -u USERNAME -pPASSWORD dbname tablename3 -w "test_id tablename3.sql
Then import on aliyun server
$ more /var/opt/sqlimport/import.sh #!/bin/bash mysql -h sql_server_1_address -u USERNAME -pPASSWORD dbname
Original link: Phanix's Blog
Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!