mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-10 22:24:13 +00:00
debug dump-repo-objs: remove --ghost
This was used for an implementation detail of the borg 1.x repository code, dumping uncommitted objects. Not needed any more. Also remove local repository method scan_low_level, it was only used by --ghost.
This commit is contained in:
parent
bfbf3ba7aa
commit
1189fc3495
3 changed files with 16 additions and 87 deletions
|
@ -11,11 +11,11 @@ from ..helpers import sysinfo
|
|||
from ..helpers import bin_to_hex, hex_to_bin, prepare_dump_dict
|
||||
from ..helpers import dash_open
|
||||
from ..helpers import StableDict
|
||||
from ..helpers import positive_int_validator, archivename_validator
|
||||
from ..helpers import archivename_validator
|
||||
from ..helpers import CommandError, RTError
|
||||
from ..manifest import Manifest
|
||||
from ..platform import get_process_id
|
||||
from ..repository import Repository, TAG_PUT, TAG_DELETE, TAG_COMMIT
|
||||
from ..repository import Repository
|
||||
from ..repository3 import Repository3, LIST_SCAN_LIMIT
|
||||
from ..repoobj import RepoObj
|
||||
|
||||
|
@ -127,40 +127,21 @@ class DebugMixIn:
|
|||
with open(filename, "wb") as fd:
|
||||
fd.write(data)
|
||||
|
||||
if args.ghost:
|
||||
# dump ghosty stuff from segment files: not yet committed objects, deleted / superseded objects, commit tags
|
||||
|
||||
# set up the key without depending on a manifest obj
|
||||
for id, cdata, tag, segment, offset in repository.scan_low_level():
|
||||
if tag == TAG_PUT:
|
||||
key = key_factory(repository, cdata)
|
||||
repo_objs = RepoObj(key)
|
||||
break
|
||||
i = 0
|
||||
for id, cdata, tag, segment, offset in repository.scan_low_level(segment=args.segment, offset=args.offset):
|
||||
if tag == TAG_PUT:
|
||||
decrypt_dump(i, id, cdata, tag="put", segment=segment, offset=offset)
|
||||
elif tag == TAG_DELETE:
|
||||
decrypt_dump(i, id, None, tag="del", segment=segment, offset=offset)
|
||||
elif tag == TAG_COMMIT:
|
||||
decrypt_dump(i, None, None, tag="commit", segment=segment, offset=offset)
|
||||
# set up the key without depending on a manifest obj
|
||||
ids = repository.list(limit=1, marker=None)
|
||||
cdata = repository.get(ids[0])
|
||||
key = key_factory(repository, cdata)
|
||||
repo_objs = RepoObj(key)
|
||||
state = None
|
||||
i = 0
|
||||
while True:
|
||||
ids, state = repository.scan(limit=LIST_SCAN_LIMIT, state=state) # must use on-disk order scanning here
|
||||
if not ids:
|
||||
break
|
||||
for id in ids:
|
||||
cdata = repository.get(id)
|
||||
decrypt_dump(i, id, cdata)
|
||||
i += 1
|
||||
else:
|
||||
# set up the key without depending on a manifest obj
|
||||
ids = repository.list(limit=1, marker=None)
|
||||
cdata = repository.get(ids[0])
|
||||
key = key_factory(repository, cdata)
|
||||
repo_objs = RepoObj(key)
|
||||
state = None
|
||||
i = 0
|
||||
while True:
|
||||
ids, state = repository.scan(limit=LIST_SCAN_LIMIT, state=state) # must use on-disk order scanning here
|
||||
if not ids:
|
||||
break
|
||||
for id in ids:
|
||||
cdata = repository.get(id)
|
||||
decrypt_dump(i, id, cdata)
|
||||
i += 1
|
||||
print("Done.")
|
||||
|
||||
@with_repository(manifest=False)
|
||||
|
@ -469,30 +450,6 @@ class DebugMixIn:
|
|||
help="dump repo objects (debug)",
|
||||
)
|
||||
subparser.set_defaults(func=self.do_debug_dump_repo_objs)
|
||||
subparser.add_argument(
|
||||
"--ghost",
|
||||
dest="ghost",
|
||||
action="store_true",
|
||||
help="dump all segment file contents, including deleted/uncommitted objects and commits.",
|
||||
)
|
||||
subparser.add_argument(
|
||||
"--segment",
|
||||
metavar="SEG",
|
||||
dest="segment",
|
||||
type=positive_int_validator,
|
||||
default=None,
|
||||
action=Highlander,
|
||||
help="used together with --ghost: limit processing to given segment.",
|
||||
)
|
||||
subparser.add_argument(
|
||||
"--offset",
|
||||
metavar="OFFS",
|
||||
dest="offset",
|
||||
type=positive_int_validator,
|
||||
default=None,
|
||||
action=Highlander,
|
||||
help="used together with --ghost: limit processing to given offset.",
|
||||
)
|
||||
|
||||
debug_search_repo_objs_epilog = process_epilog(
|
||||
"""
|
||||
|
|
|
@ -1186,31 +1186,6 @@ class Repository:
|
|||
logger.info("Finished %s repository check, no problems found.", mode)
|
||||
return not error_found or repair
|
||||
|
||||
def scan_low_level(self, segment=None, offset=None):
|
||||
"""Very low level scan over all segment file entries.
|
||||
|
||||
It does NOT care about what's committed and what not.
|
||||
It does NOT care whether an object might be deleted or superseded later.
|
||||
It just yields anything it finds in the segment files.
|
||||
|
||||
This is intended as a last-resort way to get access to all repo contents of damaged repos,
|
||||
when there is uncommitted, but valuable data in there...
|
||||
|
||||
When segment or segment+offset is given, limit processing to this location only.
|
||||
"""
|
||||
for current_segment, filename in self.io.segment_iterator(start_segment=segment, end_segment=segment):
|
||||
try:
|
||||
for tag, key, current_offset, _, data in self.io.iter_objects(
|
||||
segment=current_segment, offset=offset or 0
|
||||
):
|
||||
if offset is not None and current_offset > offset:
|
||||
break
|
||||
yield key, data, tag, current_segment, current_offset
|
||||
except IntegrityError as err:
|
||||
logger.error(
|
||||
"Segment %d (%s) has IntegrityError(s) [%s] - skipping." % (current_segment, filename, str(err))
|
||||
)
|
||||
|
||||
def _rollback(self, *, cleanup):
|
||||
if cleanup:
|
||||
self.io.cleanup(self.io.get_segments_transaction_id())
|
||||
|
|
|
@ -282,9 +282,6 @@ class Repository3:
|
|||
logger.error(f"Finished {mode} repository check, errors found.")
|
||||
return objs_errors == 0 or repair
|
||||
|
||||
def scan_low_level(self, segment=None, offset=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def __len__(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue