---
- hosts: 'all'
gather_facts: no
vars_files:
- 'vars/main.yml'
tasks:
- name: 'Sync'
synchronize: src=/var/www/{{ username }}/ dest=/var/backups/{{ username }} owner=no group=no delete=yes
tags: 'update'
- name: 'DB backup'
mysql_db: state=dump name={{ username }} target=/var/backups/{{ username }}/{{ username }}.sql login_user=root login_password={{ mysql_root_pass }}
tags: 'update'
- name: 'Sync restore'
synchronize:
src: /var/backups/{{ username }}
dest: /var/www/
delete: yes
rsync_opts:
- "--exclude=.sql"
become: yes
become_user: "{{ username }}"
tags: 'restore'
- name: 'Del MySQL database'
mysql_db: name={{ username }} login_user=root login_password={{ mysql_root_pass }} state=absent
tags: 'restore'
- name: 'Add MySQL DB'
mysql_db: name={{ username }} encoding=utf8 login_user=root login_password={{ mysql_root_pass }} state=present
tags: 'restore'
- name: 'DB restore'
mysql_db: state=import name={{ username }} target=/var/backups/{{ username }}/{{ username }}.sql login_user=root login_password={{ mysql_root_pass }}
tags: 'restore'
php /domain/public_html/ yii hello/world