diff --git a/frappe/model/db_schema.py b/frappe/model/db_schema.py index 64d7daca71..79b7a0bd4a 100644 --- a/frappe/model/db_schema.py +++ b/frappe/model/db_schema.py @@ -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"""