Quantcast
Channel: Planet MySQL
Viewing all articles
Browse latest Browse all 18788

ProxySQL Config file creation | Backup solution

$
0
0

We are well aware that ProxySQL is one of the powerful SQL aware proxy for MySQL. The ProxySQL configuration is flexible and the maximum part of configurations can be done with the ProxySQL client itself.

The latest ProxySQL release ( 2.0.9 ) has few impressive features like “SQL injection engine, Firewall whitelist, Config file generate” . In this blog I am going to explain, how to generate the ProxySQL config file using the proxySQL client .

Why configuration file ?

  • Backup solution
  • Helpful for Ansible deployments in multipul environments

There are two important commands involved in the ProxySQL config file generation.

  • Print the config file text in ProxySQL client itself ( like query output )
  • Export the configurations in separate file

Print the config file text in ProxySQL client ( like query output ) :

cmd : SELECT CONFIG FILE ;

Export the configurations in separate file :

cmd : SELECT CONFIG INTO OUTFILE /path/config

Below is the bash script , which will helps to backup the ProxySQL configuration . It can be schedule in the cron with convenient time .

Script :

[root@ip-172-31-8-156 ProxySQL]# cat backup.sh
#!/bin/sh

#variable

backup_path="/var/lib/ProxySQL_backup/data"
user=admin
pass=admin
port=6032
host=127.0.0.1
back_name=ProxySQL_backup_$(date -u +%Y-%m-%dT%H-%M-%S)
log_path="/var/lib/ProxySQL_backup/log"

#live_check

ProxySQL_livecheck() {
if [[ $(pgrep proxysql) ]]; then 
      ProxySQL_Backup 
else 
      echo "Backup ( $back_name ) failed" >> /var/lib/ProxySQL_backup/log/backup.err 
      exit 
fi
}

#backup

ProxySQL_Backup() {
mysql -u$user -p$pass -P$port -h$host -e "select config into outfile $backup_path/$back_name" 

echo "Backup ( $back_name ) completed" >> /var/lib/ProxySQL_backup/log/backup.log
}

#call
ProxySQL_livecheck

Thanks !!!


Viewing all articles
Browse latest Browse all 18788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>