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 <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2023-10-26 15:37:49 +05:30
parent 7db8baa7c4
commit 0b508e2a96
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -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,