Skip to content

Commit

Permalink
check --undelete-archives: support running with or without --repair
Browse files Browse the repository at this point in the history
Without --repair, it can be used to detect such inconsistencies and return with rc != 0.
  • Loading branch information
ThomasWaldmann committed Nov 3, 2024
1 parent 4682ce6 commit e3caab9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1864,14 +1864,18 @@ def valid_archive(obj):
archive = ArchiveItem(internal_dict=archive)
name = archive.name
archive_id, archive_id_hex = chunk_id, bin_to_hex(chunk_id)
logger.info(f"Found archive {name} {archive_id_hex}.")
if self.manifest.archives.exists_id(archive_id, deleted=False):
logger.debug(f"We already have an archives directory entry for {name} {archive_id_hex}.")
elif self.manifest.archives.exists_id(archive_id, deleted=True):
logger.debug(f"We already have a deleted archives directory entry for {name} {archive_id_hex}.")
else:
logger.warning(f"Creating archives directory entry for {name} {archive_id_hex}.")
self.manifest.archives.create(name, archive_id, archive.time)
self.error_found = True
if self.repair:
logger.warning(f"Creating archives directory entry for {name} {archive_id_hex}.")
self.manifest.archives.create(name, archive_id, archive.time)
else:
logger.warning(f"Would create archives directory entry for {name} {archive_id_hex}.")

pi.finish()
logger.info("Rebuilding missing archives directory entries completed.")

Expand Down
2 changes: 0 additions & 2 deletions src/borg/archiver/check_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def do_check(self, args, repository):
)
if args.repair and args.max_duration:
raise CommandError("--repair does not allow --max-duration argument.")
if args.undelete_archives and not args.repair:
raise CommandError("--undelete-archives requires --repair argument.")
if args.max_duration and not args.repo_only:
# when doing a partial repo check, we can only check xxh64 hashes in repository files.
# archives check requires that a full repo check was done before and has built/cached a ChunkIndex.
Expand Down

0 comments on commit e3caab9

Please sign in to comment.