Playbook to backup all mysql databases

0 votes
Can I have an ansible playbook that backups all the mysql databases?
Feb 4 in Ansible by Ruth
126 views

1 answer to this question.

0 votes

Hey @Ruth, you could use a playbook, something like this:

- name: backup mysql
  vars:
    - exclude_db:
      - "Database"
      - "information_schema"
      - "performance_schema"
      - "mysql"
  tasks:
    - name: get db names
      shell: 'mysql -u root -p{{ vault_root_passwd }} -e "show databases;" '
      register: dblist
    - name: backup databases
      mysql_db:
        state: dump
        name: "{{ item }}"
        target: "/tmp/{{ item }}.sql"
        login_user: root
        login_password: "{{ vault_root_passwd }}"
      with_items: "{{ dblist.stdout_lines | difference(exclude_db) }}"
answered Feb 4 by Anushri

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Running to plays in one playbook

The inventory file is loaded before a ...READ MORE

answered Jun 25, 2018 in Ansible by ajs3033
• 7,240 points
24 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
72 views
+1 vote
4 answers

Pass variable to ansible playbook through command line

ansible-playbook test.yml --extra-vars "arg1=${var1} arg2=${var2}" Use is like ...READ MORE

answered May 7 in Ansible by Bobin
2,029 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How do i set multiple authorized keys to my ansible playbook?

Try this: - name: Set up multiple authorized ...READ MORE

answered Feb 11 in Ansible by John
40 views
0 votes
1 answer

Playbook to start ec2 instance

- name: Create an ec2 instance ...READ MORE

answered Apr 8 in Ansible by Kalgi
17 views