Commit e5608dba authored by Visay Keo's avatar Visay Keo
Browse files

[FEATURE] Introduce --from-cache switch

parent cd9fb23c
Loading
Loading
Loading
Loading
+5 −0
Changes for CHANGELOG: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
CHANGELOG
=========

3.0.6
-----

  - [FEATURE] Introduce --from-cache switch

3.0.5
-----

+3 −2
Changes for README.md: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ This is requires that your Flow Framework / Neos CMS installation is configured
(see https://github.com/Sebobo/Shel.DockerFlow) or your TYPO3 installation is configured to run with `dockertypo3`
package (see https://github.com/visay/DockerTYPO3) and all containers are started before executing the sync.

Ansible is needed on your local installation machine.
Ansible is needed on your local machine.

## Installation

@@ -56,6 +56,7 @@ bin-dir/syncontent -u=demo-014-007 -h=10.10.10.37 -p=/home/user/neosbox
- `-t` | `--ansible-tags`: Set the specific task you want run. See available sync tasks section for details
- `--remote-php`         : Set the path to php on the remote server
- `--remote-dump`        : Set the sql dump location on the remote server. It must contain the absolute path and filename
- `--from-cache`         : Use local caches of files and database dump from previous run instead of getting fresh from remote
- `-v`                   : Set the verbosity of ansible output. You can also set more verbose by adding more `v` like `-vvvvv`
- `--dry-run`            : Force to display the command to execute but won't run them. Useful for debugging when you want
                           to see the full ansible command and maybe execute them directly for better error hints
@@ -172,7 +173,7 @@ They run in the following order for Flow Framework:
- resource:publish
- cache:warmup

Add for TYPO3 CMS (`helhum/typo3-console` package is required for this part to run):
And for TYPO3 CMS (`helhum/typo3-console` package is required for this part to run):

- cache:flush
- database:updateschema --schema-update-types=field.add
+3 −33
Changes for ansible/roles/database/tasks/flow.yml: 3 added lines, 33 removed lines.
Original line number Diff line number Diff line
---
# tasks file for flow database

  - name: Read remote database info (FLOW_CONTEXT=Production)
    shell: FLOW_CONTEXT=Production {{ remote_php | default('') }} ./flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions chdir="{{ remote_path }}"
    register: db_info

  - name: Get remote database host
    shell: echo "{{ db_info.stdout }}" | grep "host:" | cut -d ' ' -f2
    register: db_host

  - name: Get remote database name
    shell: echo "{{ db_info.stdout }}" | grep "dbname:" | cut -d ' ' -f2
    register: db_name

  - name: Get remote database user
    shell: echo "{{ db_info.stdout }}" | grep "user:" | cut -d ' ' -f2
    register: db_user

  - name: Get remote database password
    shell: echo "{{ db_info.stdout }}" | grep "password:" | cut -d ' ' -f2
    register: db_pass

  - name: Dump remote database
    mysql_db: login_host="{{ db_host.stdout }}"
              login_user="{{ db_user.stdout }}"
              login_password="{{ db_pass.stdout }}"
              name="{{ db_name.stdout }}"
              state=dump
              target={{ remote_dump }}/{{ db_name.stdout }}.sql
              encoding=utf8
              collation=utf8_unicode_ci

  - name: Sync remote database dump to local temp
    synchronize: mode=pull src="/{{ remote_dump }}/{{ db_name.stdout }}.sql" dest="/tmp/{{ db_name.stdout }}.sql"
  - include: flow_db_dump.yml
    when: not from_cache|bool

  - name: Check local database name
    local_action: shell FLOW_CONTEXT={{ local_context }} {{ bin_path }}/dockerflow run -T app ./flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions | grep 'dbname' | cut -d ' ' -f2
@@ -48,5 +18,5 @@
                  chdir="{{ local_path }}"

  - name: Restore local database from remote dump
    local_action: shell {{ bin_path }}/dockerflow run db mysql -h db -u root -proot {{ local_db_name.stdout }} < /tmp/{{ db_name.stdout }}.sql
    local_action: shell {{ bin_path }}/dockerflow run db mysql -h db -u root -proot {{ local_db_name.stdout }} < /tmp/{{ ssh_user }}/db_dump.sql
                  chdir="{{ local_path }}"
+35 −0
Changes for ansible/roles/database/tasks/flow_db_dump.yml: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
---
# tasks file for flow database

  - name: Read remote database info (FLOW_CONTEXT=Production)
    shell: FLOW_CONTEXT=Production {{ remote_php | default('') }} ./flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions chdir="{{ remote_path }}"
    register: db_info

  - name: Get remote database host
    shell: echo "{{ db_info.stdout }}" | grep "host:" | cut -d ' ' -f2
    register: db_host

  - name: Get remote database name
    shell: echo "{{ db_info.stdout }}" | grep "dbname:" | cut -d ' ' -f2
    register: db_name

  - name: Get remote database user
    shell: echo "{{ db_info.stdout }}" | grep "user:" | cut -d ' ' -f2
    register: db_user

  - name: Get remote database password
    shell: echo "{{ db_info.stdout }}" | grep "password:" | cut -d ' ' -f2
    register: db_pass

  - name: Dump remote database
    mysql_db: login_host="{{ db_host.stdout }}"
              login_user="{{ db_user.stdout }}"
              login_password="{{ db_pass.stdout }}"
              name="{{ db_name.stdout }}"
              state=dump
              target={{ remote_dump }}/{{ db_name.stdout }}.sql
              encoding=utf8
              collation=utf8_unicode_ci

  - name: Sync remote database dump to local temp
    synchronize: mode=pull src="/{{ remote_dump }}/{{ db_name.stdout }}.sql" dest="/tmp/{{ ssh_user }}/db_dump.sql"
+3 −2
Changes for ansible/roles/database/tasks/typo3.yml: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
# tasks file for typo3 database

  - name: Sync remote database dump to local temp
    synchronize: mode=pull src="{{ remote_dump }}" dest="/tmp/{{ ssh_user }}.sql"
    synchronize: mode=pull src="{{ remote_dump }}" dest="/tmp/{{ ssh_user }}/db_dump.sql"
    when: not from_cache|bool

  - name: Drop local database
    local_action: shell {{ bin_path }}/dockertypo3 run db mysqladmin -h db -u root -proot drop dockertypo3 -f
@@ -13,5 +14,5 @@
                  chdir="{{ local_path }}"

  - name: Restore local database from remote dump
    local_action: shell {{ bin_path }}/dockertypo3 run db mysql -h db -u root -proot dockertypo3 < /tmp/{{ ssh_user }}.sql
    local_action: shell {{ bin_path }}/dockertypo3 run db mysql -h db -u root -proot dockertypo3 < /tmp/{{ ssh_user }}/db_dump.sql
                  chdir="{{ local_path }}"
Loading