From 0b508e2a961807ea8784255a64b71cb6afe6ae22 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Thu, 26 Oct 2023 15:37:49 +0530 Subject: [PATCH] feat(db_manager): avoid extraction of DB dump if gzipped Use `gzip -cd` to directly get the contents onto stdout and pipe to mariadb Signed-off-by: Akhil Narang --- frappe/database/db_manager.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/frappe/database/db_manager.py b/frappe/database/db_manager.py index 68cd39f2f5..27704fb472 100644 --- a/frappe/database/db_manager.py +++ b/frappe/database/db_manager.py @@ -61,12 +61,23 @@ class DbManager: command = [] - if pv: - command.extend([pv, source, "|"]) - source = [] - print("Restoring Database file...") + if source.endswith(".gz"): + if gzip := which("gzip"): + source = [] + command.extend([gzip, "-cd", source, "|"]) + if pv: + command.extend([pv, "|"]) + print("Restoring Database file...") + else: + raise Exception("`gzip` not installed") + else: - source = ["<", source] + if pv: + command.extend([pv, source, "|"]) + source = [] + print("Restoring Database file...") + else: + source = ["<", source] bin, args, bin_name = get_command( host=frappe.conf.db_host,