Skip to content

Commit

Permalink
Fix to enable the creation of backups when a backup name is not provi…
Browse files Browse the repository at this point in the history
…ded (#758)
  • Loading branch information
VenkataNaladala94 authored May 6, 2024
1 parent 69e00a4 commit db850a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion medusa/backup_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions medusa/medusacli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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')
Expand All @@ -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,
Expand Down

0 comments on commit db850a5

Please # to comment.