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
925 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 8, 2019 in Ansible by Anshul
172 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 20 in Ansible by MD
• 57,060 points
15 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,280 points
164 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
682 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 11, 2019 in Ansible by John
260 views
0 votes
1 answer

Playbook to start ec2 instance

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

answered Apr 8, 2019 in Ansible by Kalgi
108 views