mysql has commands to perform the functions you need, just add them to the script along with the proper authentication.
On the remote server either copy the script over and use ssh to run the script or put it in crontabs on either or both servers.
Best bet, add a mysql user to each server who can run the scripts. Add the scripts to each server's crontab or "at" if you can't write to crontab. Make sure the mysql user has an .ssh directory on both servers and no password (for unattended execution of the script). Copy each .ssh/public_key to the opposite server and ssh should work both ways.