From db850a502207c04a55d749179bb87f19a317b449 Mon Sep 17 00:00:00 2001 From: VenkataNaladala94 <134724067+VenkataNaladala94@users.noreply.github.com> Date: Mon, 6 May 2024 05:58:54 -0400 Subject: [PATCH] Fix to enable the creation of backups when a backup name is not provided (#758) --- medusa/backup_cluster.py | 2 +- medusa/medusacli.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/medusa/backup_cluster.py b/medusa/backup_cluster.py index ed5580499..b18003467 100644 --- a/medusa/backup_cluster.py +++ b/medusa/backup_cluster.py @@ -32,7 +32,7 @@ def orchestrate(config, backup_name_arg, seed_target, stagger, enable_md5_checks parallel_snapshots, parallel_uploads, orchestration_snapshots=None, orchestration_uploads=None, cassandra_config=None, monitoring=None, existing_storage=None, cql_session_provider=None): backup = None - backup_name = backup_name_arg or datetime.datetime.now().strftime('%Y%m%d%H%M') + backup_name = backup_name_arg monitoring = Monitoring(config=config.monitoring) if monitoring is None else monitoring if existing_storage is None: diff --git a/medusa/medusacli.py b/medusa/medusacli.py index ff460fe6e..1c3f63a81 100644 --- a/medusa/medusacli.py +++ b/medusa/medusacli.py @@ -116,7 +116,7 @@ def cli(ctx, verbosity, without_log_timestamp, config_file, **kwargs): @cli.command(aliases=['backup', 'backup-node']) -@click.option('--backup-name', help='Custom name for the backup') +@click.option('--backup-name', help='Backup name of the backup, defaults to current datetime (formatted "%Y%m%dT%H%M")') @click.option('--stagger', default=None, type=int, help='Drop initial backups if longer than a duration in seconds') @click.option('--enable-md5-checks', help='During backups and verify, use md5 calculations to determine file integrity ' @@ -129,8 +129,9 @@ def backup(medusaconfig, backup_name, stagger, enable_md5_checks, mode): Backup single Cassandra node """ stagger_time = datetime.timedelta(seconds=stagger) if stagger else None - BackupMan.register_backup(backup_name, is_async=False) - return backup_node.handle_backup(medusaconfig, backup_name, stagger_time, enable_md5_checks, mode) + actual_backup_name = backup_name or datetime.datetime.now().strftime('%Y%m%d%H%M') + BackupMan.register_backup(actual_backup_name, is_async=False) + return backup_node.handle_backup(medusaconfig, actual_backup_name, stagger_time, enable_md5_checks, mode) @cli.command(name='backup-cluster') @@ -154,8 +155,9 @@ def backup_cluster(medusaconfig, backup_name, seed_target, stagger, enable_md5_c """ Backup Cassandra cluster """ + actual_backup_name = backup_name or datetime.datetime.now().strftime('%Y%m%d%H%M') medusa.backup_cluster.orchestrate(medusaconfig, - backup_name, + actual_backup_name, seed_target, stagger, enable_md5_checks,