- name: Drop newly created keitaro DB
  shell: mysql -e "DROP DATABASE {{ db_name }}; CREATE DATABASE {{ db_name }}"

- name: Install file utility
  package:
    name: file
    state: present

- name: Get mime of dump
  shell: "file '{{ db_restore_path }}' --mime-type --brief"
  args:
    chdir: ../
  register: db_restore_dump_file_mime

- name: Restore DB from gzipped SQL dump
  include: restore_from_packed_dump.yml cat=zcat
  when: "db_restore_dump_file_mime.stdout == 'application/x-gzip'"

- name: Restore DB from unpacked SQL dump
  include: restore_from_unpacked_dump.yml
  when: "db_restore_dump_file_mime.stdout != 'application/x-gzip'"

- name: Reset Keitaro salt
  lineinfile:
    path: "{{ keitaro.path }}/application/config/config.ini.php"
    regexp: '^salt'
    line: 'salt = {{ db_restore_salt }}'
  notify: restart php-fpm



- name: Drop newly created keitaro DB
  shell: 'mysql -e "DROP DATABASE {{ db_name }}; CREATE DATABASE {{ db_name }}"'

- name: Install file utility
  package:
    name: file
    state: present

- name: Get mime of dump
  shell: "file '{{ db_restore_path }}' --mime-type --brief"
  args:
    chdir: ../
  register: db_restore_dump_file_mime

- name: Restore DB from gzipped SQL dump
  include: restore_from_packed_dump.yml cat=zcat
  when: "db_restore_dump_file_mime.stdout == 'application/x-gzip'"

- name: Restore DB from unpacked SQL dump
  include: restore_from_unpacked_dump.yml
  when: "db_restore_dump_file_mime.stdout != 'application/x-gzip'"

- name: Reset Keitaro cache
  shell: "php bin/cli.php system:reload_cache"
  args:
    chdir: "{{ keitaro.path }}"

- name: Reset Keitaro salt
  lineinfile:
    path: "{{ keitaro.path }}/application/config/config.ini.php"
    regexp: '^salt'
    line: 'salt = {{ db_restore_salt }}'
  notify: restart php-fpm



Reset Keitaro cache after restoring from dump
Reset Keitaro cache after restoring from dump
