mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 03:29:03 +00:00
ISSUE-13517: Added option to explicitly specify backup filename (#13661)
* ISSUE-13517: Added option to explicitly specify output filename for metadata backup * format --------- Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
This commit is contained in:
parent
32ac45f11f
commit
74aef36b1e
@ -32,7 +32,7 @@ class UploadDestinationType(Enum):
|
||||
logger = cli_logger()
|
||||
|
||||
|
||||
def get_output(output: Optional[str] = None) -> Path:
|
||||
def get_output(output: Optional[str] = None, filename: Optional[str] = None) -> Path:
|
||||
"""
|
||||
Helper function to prepare the output backup file
|
||||
path and name.
|
||||
@ -40,10 +40,11 @@ def get_output(output: Optional[str] = None) -> Path:
|
||||
It will create the output dir if it does not exist.
|
||||
|
||||
:param output: local path to store the backup
|
||||
:param filename: name of the backup file
|
||||
:return: backup file name
|
||||
"""
|
||||
now = datetime.now().strftime("%Y%m%d%H%M")
|
||||
name = f"openmetadata_{now}_backup.sql"
|
||||
name = filename if filename else f"openmetadata_{now}_backup.sql"
|
||||
|
||||
if output:
|
||||
path = Path(output).expanduser()
|
||||
@ -160,6 +161,7 @@ def upload_backup_azure(account_url: str, container: str, file: Path) -> None:
|
||||
def run_backup(
|
||||
common_backup_obj_instance: BackupRestoreArgs,
|
||||
output: Optional[str],
|
||||
filename: Optional[str],
|
||||
upload_destination_type: Optional[UploadDestinationType],
|
||||
upload: Optional[Tuple[str, str, str]],
|
||||
) -> None:
|
||||
@ -169,6 +171,7 @@ def run_backup(
|
||||
|
||||
:param common_backup_obj_instance: cls instance to fetch common args
|
||||
:param output: local path to store the backup
|
||||
:param filename: filename to store the backup
|
||||
:param upload_destination_type: Azure or AWS Destination Type
|
||||
:param upload: URI to upload result file
|
||||
|
||||
@ -180,7 +183,7 @@ def run_backup(
|
||||
f"{common_backup_obj_instance.host}:{common_backup_obj_instance.port}/{common_backup_obj_instance.database}...",
|
||||
)
|
||||
|
||||
out = get_output(output)
|
||||
out = get_output(output, filename)
|
||||
|
||||
engine = get_engine(common_args=common_backup_obj_instance)
|
||||
dump(engine=engine, output=out, schema=common_backup_obj_instance.schema)
|
||||
|
||||
@ -236,6 +236,11 @@ def backup_args(parser: argparse.ArgumentParser):
|
||||
type=Path,
|
||||
default=None,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--filename",
|
||||
help="Filename to store the backup",
|
||||
default=None,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--upload-destination-type",
|
||||
help="AWS or AZURE",
|
||||
@ -444,6 +449,7 @@ def metadata(args=None): # pylint: disable=too-many-branches
|
||||
schema=contains_args.get("schema"),
|
||||
),
|
||||
output=contains_args.get("output"),
|
||||
filename=contains_args.get("filename"),
|
||||
upload_destination_type=contains_args.get("upload_destination_type"),
|
||||
upload=contains_args.get("upload"),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user