chore: handle restoring gzipped backups
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
368d7ae298
commit
6e31745290
1 changed files with 8 additions and 1 deletions
|
|
@ -54,7 +54,14 @@ def copy_db(db_file=None, verbose=False):
|
|||
destination_db_folder.mkdir()
|
||||
destination_db_path = destination_db_folder / f"{db_name}.db"
|
||||
|
||||
shutil.copy(db_path, destination_db_path)
|
||||
if db_path.suffix == ".gz":
|
||||
import gzip
|
||||
|
||||
with gzip.open(db_file, "rb") as input, open(destination_db_path, "wb") as output:
|
||||
shutil.copyfileobj(input, output)
|
||||
|
||||
else:
|
||||
shutil.copy(db_path, destination_db_path)
|
||||
if verbose:
|
||||
print("Imported from database {}".format(db_path))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue