Commit 5cc9ce49 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Improve db_import logic

parent 1fadbec9
......@@ -27,7 +27,6 @@ from datetime import datetime
import os.path
import helpers as h
import core as c
......@@ -124,12 +123,12 @@ def site_install():
db_host, db_name, site_name,
print green('Site installed successfully!')
# Import db_dump if it exists.
if env.db_dump:
if 'db_dump' in env and env.db_dump is not False:
print green('Site installed successfully!')
h.hook_execute('post_install', role)
......@@ -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.')
print red('Could not find database dump at {}'.format(filename))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment