dbtool: update backup location
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
2392ccd719
commit
46a92e1900
|
@ -9,6 +9,7 @@ import pathlib
|
|||
import base64
|
||||
import tempfile
|
||||
import re
|
||||
import time
|
||||
from typing import Any, Dict, Optional, TextIO, Tuple
|
||||
import lmdb
|
||||
|
||||
|
@ -157,10 +158,13 @@ def restore(args: Dict[str, Any]):
|
|||
print(f"Restoring backup from '{input_db}' to '{dest_path}'...")
|
||||
bkp_dir: Optional[pathlib.Path] = None
|
||||
if dest_path.joinpath("data.mdb").exists():
|
||||
tmp_dir = pathlib.Path(tempfile.gettempdir())
|
||||
bkp_dir = tmp_dir.joinpath("moonrakerdb_backup")
|
||||
bkp_dir = dest_path.parent.joinpath("backup")
|
||||
if not bkp_dir.exists():
|
||||
bkp_dir = pathlib.Path(tempfile.gettempdir())
|
||||
str_time = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime())
|
||||
bkp_dir = bkp_dir.joinpath(f"{str_time}/database")
|
||||
if not bkp_dir.is_dir():
|
||||
bkp_dir.mkdir()
|
||||
bkp_dir.mkdir(parents=True)
|
||||
print(f"Warning: database file at found in '{dest_path}', "
|
||||
"all data will be overwritten. Copying existing DB "
|
||||
f"to '{bkp_dir}'")
|
||||
|
|
Loading…
Reference in New Issue