2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 23:00:56 +00:00

fix: pipe uncompressed database to file

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
Chinmay D. Pai 2020-07-10 10:07:22 +05:30
parent c67fc02452
commit 1d9dd966b1
No known key found for this signature in database
GPG Key ID: 75507BE256F40CED
2 changed files with 10 additions and 9 deletions

View File

@ -29,18 +29,17 @@ def get_backup_dir():
)
def decompress_db(files_base, site):
database_file = files_base + '-database.sql.gz'
command = ["gunzip", "-c", database_file, ">", database_file.replace(".gz", "")]
print('Extract Database GZip for site {}'.format(site))
run_command(command)
def decompress_db(database_file, site):
command = ["gunzip", "-c", database_file]
with open(database_file.replace(".gz", ""), "w") as db_file:
print('Extract Database GZip for site {}'.format(site))
run_command(command, stdout=db_file)
def restore_database(files_base, site_config_path, site):
# restore database
database_file = files_base + '-database.sql.gz'
decompress_db(files_base, site)
decompress_db(database_file, site)
config = get_config()
# Set db_type if it exists in backup site_config.json

View File

@ -1,8 +1,10 @@
import subprocess
def run_command(command):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def run_command(command, stdout=None, stderr=None):
stdout = stdout or subprocess.PIPE
stderr = stderr or subprocess.PIPE
process = subprocess.Popen(command, stdout=stdout, stderr=stderr)
out, error = process.communicate()
if process.returncode:
print("Something went wrong:")