dar-backup 0.6.4__py3-none-any.whl → 0.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dar_backup/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.4"
1
+ __version__ = "0.6.6"
dar_backup/dar_backup.py CHANGED
@@ -30,7 +30,7 @@ from dar_backup.util import RestoreError
30
30
 
31
31
  logger = None
32
32
 
33
- def generic_backup(type: str, command: List[str], backup_file: str, backup_definition: str, darrc: str, config_settings: ConfigSettings):
33
+ def generic_backup(type: str, command: List[str], backup_file: str, backup_definition: str, darrc: str, config_settings: ConfigSettings, args: argparse.Namespace):
34
34
  """
35
35
  Performs a backup using the 'dar' command.
36
36
 
@@ -64,6 +64,15 @@ def generic_backup(type: str, command: List[str], backup_file: str, backup_defin
64
64
  logger.warning("Backup completed with some files not backed up, this can happen if files are changed/deleted during the backup.")
65
65
  else:
66
66
  raise Exception(str(process))
67
+
68
+ if process.returncode == 0 or process.returncode == 5:
69
+ add_catalog_command = ['manager', '--add-specific-archive' ,backup_file, '--config-file', args.config_file, '--log-level', "debug", "--log-stdout"]
70
+ command_result = run_command(add_catalog_command, config_settings.command_timeout_secs)
71
+ if command_result.returncode == 0:
72
+ logger.info(f"Catalog for archive '{backup_file}' added successfully to its manager.")
73
+ else:
74
+ logger.error(f"Catalog for archive '{backup_file}' not added.")
75
+
67
76
  except subprocess.CalledProcessError as e:
68
77
  logger.error(f"Backup command failed: {e}")
69
78
  raise BackupError(f"Backup command failed: {e}") from e
@@ -409,19 +418,22 @@ def perform_backup(args: argparse.Namespace, config_settings: ConfigSettings, ba
409
418
  command = create_backup_command(backup_type, backup_file, args.darrc, backup_definition_path, latest_base_backup)
410
419
 
411
420
  # Perform backup
412
- generic_backup(backup_type, command, backup_file, backup_definition_path, args.darrc, config_settings)
421
+ generic_backup(backup_type, command, backup_file, backup_definition_path, args.darrc, config_settings, args)
413
422
 
414
423
  logger.info("Starting verification...")
415
- result = verify(args, backup_file, backup_definition_path, config_settings)
416
- if result:
424
+ verify_result = verify(args, backup_file, backup_definition_path, config_settings)
425
+ if verify_result:
417
426
  logger.info("Verification completed successfully.")
418
427
  else:
419
428
  logger.error("Verification failed.")
420
429
 
421
- if config_settings.par2_enabled:
430
+
431
+ if verify_result and config_settings.par2_enabled:
422
432
  logger.info("Generate par2 redundancy files.")
423
433
  generate_par2_files(backup_file, config_settings, args)
424
434
  logger.info("par2 files completed successfully.")
435
+
436
+
425
437
  except Exception as e:
426
438
  logger.exception(f"Error during {backup_type} backup process, continuing to next backup definition.")
427
439
 
@@ -461,16 +473,14 @@ def generate_par2_files(backup_file: str, config_settings: ConfigSettings, args)
461
473
  for slice_file in dar_slices:
462
474
  file_path = os.path.join(config_settings.backup_dir, slice_file)
463
475
 
464
- if args.verbose or args.log_level == "debug" or args.log_level == "trace":
465
- logger.info(f"{counter}/{number_of_slices}: Now generating par2 files for {file_path}")
476
+ logger.info(f"{counter}/{number_of_slices}: Now generating par2 files for {file_path}")
466
477
 
467
478
  # Run the par2 command to generate redundancy files with error correction
468
479
  command = ['par2', 'create', f'-r{config_settings.error_correction_percent}', '-q', '-q', file_path]
469
480
  process = run_command(command, config_settings.command_timeout_secs)
470
481
 
471
482
  if process.returncode == 0:
472
- if args.verbose or args.log_level == "debug" or args.log_level == "trace":
473
- logger.info(f"{counter}/{number_of_slices}: Done")
483
+ logger.info(f"{counter}/{number_of_slices}: Done")
474
484
  else:
475
485
  logger.error(f"Error generating par2 files for {file_path}")
476
486
  raise subprocess.CalledProcessError(process.returncode, command)
dar_backup/manager.py CHANGED
@@ -60,6 +60,7 @@ def create_db(backup_def: str, config_settings: ConfigSettings):
60
60
 
61
61
  if os.path.exists(database_path):
62
62
  logger.warning(f'"{database_path}" already exists, skipping creation')
63
+ return 0
63
64
  else:
64
65
  logger.info(f'Create catalog database: "{database_path}"')
65
66
  command = ['dar_manager', '--create' , database_path]