Playbook to backup all mysql databases

0 votes
Can I have an ansible playbook that backups all the mysql databases?
Feb 4, 2019 in Ansible by Ruth
2,646 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, 2019 by Anushri

Related Questions In Ansible

0 votes
1 answer

Playbook to get all the container's ARN's in my AWS ECS cluster

Hey @haseeb, you could try something like ...READ MORE

answered Apr 9, 2019 in Ansible by Anshul
746 views
0 votes
1 answer

How to launch MySQL docker container using Ansible playbook?

Hi@akhtar, You can use docker_container module in your ...READ MORE

answered Sep 21, 2020 in Ansible by MD
• 95,440 points
3,722 views
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,300 points
1,051 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,503 views
+2 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 12, 2019 in Ansible by John
1,198 views
0 votes
1 answer

Playbook to start ec2 instance

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

answered Apr 9, 2019 in Ansible by Kalgi
444 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP