I am trying to backup remote database using ansible and mysqldump. I have installed ansible in my local server.Generated the ssh keys. I also sent the public key to the remote server.
Everything is fine in ansible part but can't backup using ansible and mysqldump.
I tried this:
ansible -m shell -a 'mysqldump -h 192.168.10.155 -u root -proot database_name > database_name.sql' remote_server
But the backup is being created in home directory of remote_server. My requirement is that I would like to take the backup of remote_server into my local_server.
edit:
Now i using playbook:
hosts: remote_server become: yes tasks:
- name: do a mysqldump ignore_errors: yes shell: mysqldump -h 192.168.10.155 -u root -proot database_name > dbname.sql
hosts: remote_server tasks:
name: Transfer file from remote to local
synchronize:
src: /home/user/test.txt dest: /home/user/backup delegate_to: local_server
Backup is happening but how can i get the backup in the server i am running ansible from?
I studied that this can be done using playbook as well.
How can I achieve it with playbook?