-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcore.py
More file actions
22 lines (17 loc) · 740 Bytes
/
core.py
File metadata and controls
22 lines (17 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import unicode_literals
from fabric.api import task, roles, env
from fabric.colors import red, green
import helpers as h
@task
@roles('docker')
def db_import(filename, role='docker'):
"""Import and restore the specified database dump.
$ fab core.db_import:/tmp/db_dump.sql.gz
:param filename: a full path to a gzipped sql dump.
"""
if h.fab_exists(role, filename):
print green('Database dump {} found.'.format(filename))
h.fab_run(role, 'zcat {} | mysql -u{} -p{} {}'.format(filename, env.site_db_user, env.site_db_pass, env.site_db_name))
print green('Database dump successfully restored.')
else:
print red('Could not find database dump at {}'.format(filename))