Ansible Docker MySql dump

  ansible, docker, mysql

Following is the task to take the MySQL dump. I am using ansible and docker to achieve this. I am getting errors if I redirect the mysqldump to a file.

      docker_container:
        name: "{{ mysql_dump_container_name }}"
        image: mysql:8.0.20
        env:
          MYSQL_ROOT_PASSWORD: "{{ mysql_password }}"
          MYSQL_DATABASE: "{{ mysql_database }}"
        ports:
          - "3307:3307"
        volumes:
          - "{{ mysql_backup_dir }}:/backup"
        entrypoint: "mysqldump -u {{ mysql_username }} -p{{ mysql_password }} --host {{ mysql_host }} {{ mysql_database }} > 1.sql "
        detach: yes
        restart_policy: "unless-stopped"
      become: yes

I am getting the following error

mysqldump: Couldn't find table: ">"

Entrypoint message is:

            "entrypoint": [
                "mysqldump -u root -proot --host wl.cs.net TEST > 1.sql"
            ],

Could you please help me to resolve this?

Source: Docker Questions

LEAVE A COMMENT