Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Drupal
drupalizer
Commits
5cc9ce49
Commit
5cc9ce49
authored
Mar 29, 2016
by
Emmanuel Milou
Browse files
Improve db_import logic
parent
1fadbec9
Changes
2
Hide whitespace changes
Inline
Side-by-side
drush.py
View file @
5cc9ce49
...
...
@@ -27,7 +27,6 @@ from datetime import datetime
import
os.path
import
helpers
as
h
import
core
as
c
@
task
(
alias
=
'make'
)
@
roles
(
'local'
)
...
...
@@ -117,19 +116,19 @@ def site_install():
with
h
.
fab_cd
(
role
,
site_root
):
locale
=
'--locale="fr"'
if
env
.
locale
else
''
h
.
fab_run
(
role
,
'sudo -u {} drush site-install {} {} --db-url=mysql://{}:{}@{}/{} --site-name={} '
'--account-name={} --account-pass={} --sites-subdir={} -y'
.
format
(
apache
,
profile
,
locale
,
db_user
,
db_pass
,
db_host
,
db_name
,
site_name
,
site_admin_name
,
site_admin_pass
,
print
green
(
'Site installed successfully!'
)
site_subdir
))
# Import db_dump if it exists.
if
env
.
db_dump
:
c
.
db_import
()
if
'db_dump'
in
env
and
env
.
db_dump
is
not
False
:
h
.
_
db_import
(
env
.
db_dump
)
print
green
(
'Site installed successfully!'
)
h
.
hook_execute
(
'post_install'
,
role
)
...
...
helpers.py
View file @
5cc9ce49
...
...
@@ -200,3 +200,15 @@ def _init_db(role='docker'):
def
_db_import
(
filename
,
role
=
'local'
):
"""Import and restore the specified database dump.
:param filename: a full path to a gzipped sql dump.
"""
if
path
.
isfile
(
filename
):
print
green
(
'Database dump {} found.'
.
format
(
filename
))
fab_run
(
role
,
'zcat {} | mysql -u{} -p{} -h{} {}'
.
format
(
filename
,
env
.
site_db_user
,
env
.
site_db_pass
,
env
.
container_ip
,
env
.
site_db_name
))
print
green
(
'Database dump successfully restored.'
)
else
:
print
red
(
'Could not find database dump at {}'
.
format
(
filename
))
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