Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
syncontent
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Web Essentials Jira
Web Essentials Jira
Labels
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Visay Keo
syncontent
Commits
e5608dba
Commit
e5608dba
authored
Dec 22, 2015
by
Visay Keo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] Introduce --from-cache switch
parent
cd9fb23c
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
62 deletions
+126
-62
CHANGELOG
CHANGELOG
+5
-0
README.md
README.md
+3
-2
ansible/roles/database/tasks/flow.yml
ansible/roles/database/tasks/flow.yml
+3
-33
ansible/roles/database/tasks/flow_db_dump.yml
ansible/roles/database/tasks/flow_db_dump.yml
+35
-0
ansible/roles/database/tasks/main.yml
ansible/roles/database/tasks/main.yml
+4
-4
ansible/roles/database/tasks/typo3.yml
ansible/roles/database/tasks/typo3.yml
+3
-2
ansible/roles/rsync/tasks/flow.yml
ansible/roles/rsync/tasks/flow.yml
+23
-0
ansible/roles/rsync/tasks/main.yml
ansible/roles/rsync/tasks/main.yml
+3
-18
ansible/roles/rsync/tasks/typo3.yml
ansible/roles/rsync/tasks/typo3.yml
+31
-0
bin/syncontent
bin/syncontent
+16
-3
No files found.
CHANGELOG
View file @
e5608dba
CHANGELOG
CHANGELOG
=========
=========
3.0.6
-----
- [FEATURE] Introduce --from-cache switch
3.0.5
3.0.5
-----
-----
...
...
README.md
View file @
e5608dba
...
@@ -9,7 +9,7 @@ This is requires that your Flow Framework / Neos CMS installation is configured
...
@@ -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`
(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.
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
## Installation
...
@@ -56,6 +56,7 @@ bin-dir/syncontent -u=demo-014-007 -h=10.10.10.37 -p=/home/user/neosbox
...
@@ -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
-
`-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-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
-
`--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`
-
`-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
-
`--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
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:
...
@@ -172,7 +173,7 @@ They run in the following order for Flow Framework:
-
resource:publish
-
resource:publish
-
cache:warmup
-
cache:warmup
A
d
d for TYPO3 CMS (
`helhum/typo3-console`
package is required for this part to run):
A
n
d for TYPO3 CMS (
`helhum/typo3-console`
package is required for this part to run):
-
cache:flush
-
cache:flush
-
database:updateschema --schema-update-types=field.add
-
database:updateschema --schema-update-types=field.add
...
...
ansible/roles/database/tasks/flow.yml
View file @
e5608dba
---
---
# tasks file for flow database
# tasks file for flow database
-
name
:
Read remote database info (FLOW_CONTEXT=Production)
-
include
:
flow_db_dump.yml
shell
:
FLOW_CONTEXT=Production {{ remote_php | default('') }} ./flow configuration:show --type Settings --path TYPO3.Flow.persistence.backendOptions chdir="{{ remote_path }}"
when
:
not from_cache|bool
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"
-
name
:
Check local database name
-
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
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 @@
...
@@ -48,5 +18,5 @@
chdir="{{ local_path }}"
chdir="{{ local_path }}"
-
name
:
Restore local database from remote dump
-
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 }}"
chdir="{{ local_path }}"
ansible/roles/database/tasks/flow_db_dump.yml
0 → 100644
View file @
e5608dba
---
# 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"
ansible/roles/database/tasks/main.yml
View file @
e5608dba
---
---
# tasks file for database
# tasks file for database
-
include
:
flow.yml
-
include
:
flow.yml
when
:
framework == "flow"
when
:
framework == "flow"
-
include
:
typo3.yml
-
include
:
typo3.yml
when
:
framework == "typo3"
when
:
framework == "typo3"
ansible/roles/database/tasks/typo3.yml
View file @
e5608dba
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
# tasks file for typo3 database
# tasks file for typo3 database
-
name
:
Sync remote database dump to local temp
-
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
-
name
:
Drop local database
local_action
:
shell {{ bin_path }}/dockertypo3 run db mysqladmin -h db -u root -proot drop dockertypo3 -f
local_action
:
shell {{ bin_path }}/dockertypo3 run db mysqladmin -h db -u root -proot drop dockertypo3 -f
...
@@ -13,5 +14,5 @@
...
@@ -13,5 +14,5 @@
chdir="{{ local_path }}"
chdir="{{ local_path }}"
-
name
:
Restore local database from remote dump
-
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 }}"
chdir="{{ local_path }}"
ansible/roles/rsync/tasks/flow.yml
0 → 100644
View file @
e5608dba
---
# tasks file for rsync
-
name
:
Make sure local temp directory exists
local_action
:
file path="/tmp/{{ ssh_user }}/{{ item }}" state=directory
with_items
:
-
Data/Persistent/
-
name
:
Sync flow persistent data from remote server to local temp
synchronize
:
mode=pull
src="{{ remote_path }}/{{ item }}"
dest="/tmp/{{ ssh_user }}/{{ item }}"
delete=yes
with_items
:
-
Data/Persistent/
when
:
not from_cache|bool
-
name
:
Sync flow persistent data from local temp to working directory
local_action
:
synchronize src="/tmp/{{ ssh_user }}/{{ item }}"
dest="{{ local_path }}/{{ item }}"
delete=yes
with_items
:
-
Data/Persistent/
ansible/roles/rsync/tasks/main.yml
View file @
e5608dba
---
---
# tasks file for rsync
# tasks file for rsync
-
name
:
Sync flow persistent data from remote server to local
-
include
:
flow.yml
synchronize
:
mode=pull
src="{{ remote_path }}/{{ item }}"
dest="{{ local_path }}/{{ item }}"
delete=yes
with_items
:
-
Data/Persistent/
when
:
framework == "flow"
when
:
framework == "flow"
-
name
:
Sync typo3 data from remote server to local
-
include
:
typo3.yml
synchronize
:
mode=pull
src="{{ remote_path }}/{{ item }}"
dest="{{ local_path }}/{{ item }}"
delete=yes
rsync_opts="--exclude=.gitkeep --exclude=_temp_ --exclude=_processed_"
with_items
:
-
web/fileadmin/
-
web/typo3conf/l10n/
-
web/uploads/
when
:
framework == "typo3"
when
:
framework == "typo3"
ansible/roles/rsync/tasks/typo3.yml
0 → 100644
View file @
e5608dba
---
# tasks file for rsync
-
name
:
Make sure local temp directory exists
local_action
:
file path="/tmp/{{ ssh_user }}/{{ item }}" state=directory
with_items
:
-
web/fileadmin/
-
web/typo3conf/l10n/
-
web/uploads/
-
name
:
Sync typo3 data from remote server to local temp
synchronize
:
mode=pull
src="{{ remote_path }}/{{ item }}"
dest="/tmp/{{ ssh_user }}/{{ item }}"
delete=yes
rsync_opts="--exclude=.gitkeep --exclude=_temp_ --exclude=_processed_"
with_items
:
-
web/fileadmin/
-
web/typo3conf/l10n/
-
web/uploads/
when
:
not from_cache|bool
-
name
:
Sync typo3 data from local temp to working directory
local_action
:
synchronize src="/tmp/{{ ssh_user }}/{{ item }}"
dest="{{ local_path }}/{{ item }}"
delete=yes
rsync_opts="--exclude=.gitkeep --exclude=_temp_ --exclude=_processed_"
with_items
:
-
web/fileadmin/
-
web/typo3conf/l10n/
-
web/uploads/
bin/syncontent
View file @
e5608dba
...
@@ -77,6 +77,10 @@ do
...
@@ -77,6 +77,10 @@ do
REMOTE_DUMP
=
"
${
ARGS
#*=
}
"
REMOTE_DUMP
=
"
${
ARGS
#*=
}
"
shift
shift
;;
;;
--from-cache
)
FROM_CACHE
=
"
${
ARGS
}
"
shift
;;
-v
*
)
-v
*
)
VERBOSE_LEVEL
=
"
${
ARGS
}
"
VERBOSE_LEVEL
=
"
${
ARGS
}
"
shift
shift
...
@@ -244,14 +248,23 @@ ANSIBLE_EXTRA_VARS="stage=remote ssh_user=${REMOTE_USER} local_path=${ROOT_DIR}
...
@@ -244,14 +248,23 @@ ANSIBLE_EXTRA_VARS="stage=remote ssh_user=${REMOTE_USER} local_path=${ROOT_DIR}
if
[
-n
"
${
REMOTE_PHP
}
"
]
;
then
if
[
-n
"
${
REMOTE_PHP
}
"
]
;
then
ANSIBLE_EXTRA_VARS
=
"
${
ANSIBLE_EXTRA_VARS
}
remote_php=
${
REMOTE_PHP
}
"
ANSIBLE_EXTRA_VARS
=
"
${
ANSIBLE_EXTRA_VARS
}
remote_php=
${
REMOTE_PHP
}
"
fi
fi
if
[[
-n
"
${
FROM_CACHE
}
"
]]
;
then
ANSIBLE_EXTRA_VARS
=
"
${
ANSIBLE_EXTRA_VARS
}
from_cache=yes"
else
ANSIBLE_EXTRA_VARS
=
"
${
ANSIBLE_EXTRA_VARS
}
from_cache=no"
fi
echo
-e
${
GREEN
}
"ENVIRONMENT SUMMARY:"
${
NC
}
echo
-e
${
GREEN
}
"ENVIRONMENT SUMMARY:"
${
NC
}
echo
"======================="
echo
"======================="
echo
-e
"FRAMEWORK:
${
GREEN
}${
FRAMEWORK
}${
NC
}
"
echo
-e
"FRAMEWORK:
${
GREEN
}${
FRAMEWORK
}${
NC
}
"
echo
"-----------------------"
echo
"-----------------------"
echo
-e
"FROM:
${
GREEN
}${
REMOTE_USER
}${
NC
}
"
if
[[
-n
"
${
FROM_CACHE
}
"
]]
;
then
echo
-e
"ON:
${
GREEN
}${
REMOTE_HOST
}${
NC
}
"
echo
-e
"FROM:
${
GREEN
}
Local Caches
${
NC
}
"
echo
-e
"CONTEXT:
${
GREEN
}
Production
${
NC
}
"
else
echo
-e
"FROM:
${
GREEN
}${
REMOTE_USER
}${
NC
}
"
echo
-e
"ON:
${
GREEN
}${
REMOTE_HOST
}${
NC
}
"
echo
-e
"CONTEXT:
${
GREEN
}
Production
${
NC
}
"
fi
echo
"-----------------------"
echo
"-----------------------"
echo
-e
"TO:
${
GREEN
}
Local Docker
${
NC
}
"
echo
-e
"TO:
${
GREEN
}
Local Docker
${
NC
}
"
echo
-e
"CONTEXT:
${
GREEN
}${
FRAMEWORK_CONTEXT
}${
NC
}
"
echo
-e
"CONTEXT:
${
GREEN
}${
FRAMEWORK_CONTEXT
}${
NC
}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment