mysqlansibledatabase-backupsmysql-backup

How can I achieve 'incremental backup with 1 hour timing' period in mysql using Ansible Playbook based on binlog?


I have two servers. master and slave which moderated for replication. replication process is working good. Here I wants to use "incremental dump" option for every one hour and upload that to s3 bucket or another server or local machine(control machine). From the mysql documentations I have a confident to done this using binlogfile. But I have no idea where from I start.

I am following the steps which are given below. But I dont know how the binlog file changing only equivalent of incremental dump even it have all the queries what we done in the database.

I wants to take dump from slave db. How that will take dump exactly one hour time period. How can I achieve that? 

my replication code is here.

sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "CREATE TABLE db_test.mytable (name VARCHAR(100));"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "INSERT INTO db_test.mytable (name) VALUES ('ANSIBLE');"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "FLUSH TABLES WITH READ LOCK;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "SHOW MASTER STATUS;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "unlock tables;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "drop database db_test;"
sudo mysql -uroot -p'Pass@123' --connect-expired-password -e "DROP TABLE IF EXISTS db_test.mytable;"
-get master
-adding values to dummy host
-changemaster using dummyhost value 
-starting slave

Solution

  • Finally I found a solution.