Merge pull request #5009 from achillesrasquinha/restore-progress
Show Progress of Database Restore
This commit is contained in:
commit
ec3aedf358
1 changed files with 25 additions and 2 deletions
|
|
@ -551,8 +551,31 @@ class DbManager:
|
|||
def restore_database(self,target,source,user,password):
|
||||
from frappe.utils import make_esc
|
||||
esc = make_esc('$ ')
|
||||
os.system("mysql -u %s -p%s -h%s %s < %s" % \
|
||||
(esc(user), esc(password), esc(frappe.db.host), esc(target), source))
|
||||
|
||||
from distutils.spawn import find_executable
|
||||
pipe = find_executable('pv')
|
||||
if pipe:
|
||||
pipe = '{pipe} {source} |'.format(
|
||||
pipe = pipe,
|
||||
source = source
|
||||
)
|
||||
source = ''
|
||||
else:
|
||||
pipe = ''
|
||||
source = '< {source}'.format(source = source)
|
||||
|
||||
if pipe:
|
||||
print('Creating Database...')
|
||||
|
||||
command = '{pipe} mysql -u {user} -p{password} -h{host} {target} {source}'.format(
|
||||
pipe = pipe,
|
||||
user = esc(user),
|
||||
password = esc(password),
|
||||
host = esc(frappe.db.host),
|
||||
target = esc(target),
|
||||
source = source
|
||||
)
|
||||
os.system(command)
|
||||
|
||||
def drop_table(self,table_name):
|
||||
"""drop table if exists"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue