the automysqlbackup dilemma
So, I decided to use AutoMySQLBackup to maintain our internal MySQL server backups. Unfortunately, this posed a problem with a certain server monitoring service that rhymes with Shamix (let's just keep it that way). The problem is that "Shamix" places a lock on the database tables and this causes everything to break on the monitoring end, sending a ton load of false positive alerts.
The solution was very easy. Stop the monitoring servers from reading or writing to the database tables while AutoMySQLBackup ran. To solve the issue, the backup script does allow you to execute command pre/post backup. This means I can issue command to the remote hosts from the MySQL server to perform certain tasks.
Disclaimer: What I've done is by no means secured and should not be used in a production environment.
- Create a user, call it whatever you like. Make sure that you generate the SSH key for the user in the user home directory. Copy the necessary bits for SSH authentication to the remote server (s).
- Add the user to the "wheel" group on the remote hosts.
- Modify /etc/sudoers. (I'm using RHEL)
- Comment "Defaults requiretty". If you don't then, the remote host will throw a bunch of errors.
- Uncomment "%wheel ALL=(ALL) NOPASSWD: ALL".
- Make sure that you can SSH from the MySQL server to the remote hosts without pass-phrase challenges.
- Setup the scripts in the user's home directory (/home/[user]/) and CHMOD it to be an executable. This script is available for download here.
- Edit AutoMySQLBackup, look for "PREBACKUP" and add the following: su - [user] -c /home/[user]/[script].sh
- This means the script will be executed as [user].
- Repeat the same step for "POSTBACKUP" and modify the stop commands to start.
- Save AutoMySQLBackup script and give it a whirl!
Enjoy!