1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 17:27:31 +00:00

check: replace --phase with --repository/archives-only

This commit is contained in:
Jonas Borgström 2014-03-04 21:56:37 +01:00
parent 477e1a39dd
commit 55a26e553f
2 changed files with 17 additions and 15 deletions

View file

@ -73,13 +73,13 @@ def do_check(self, args):
Type "Yes I am sure" if you understand this and want to continue.\n""") Type "Yes I am sure" if you understand this and want to continue.\n""")
if input('Do you want to continue? ') == 'Yes I am sure': if input('Do you want to continue? ') == 'Yes I am sure':
break break
if args.phase in ('all', 'repository'): if not args.archives_only:
print('Starting repository check...') print('Starting repository check...')
if repository.check(repair=args.repair): if repository.check(repair=args.repair):
print('Repository check complete, no problems found.') print('Repository check complete, no problems found.')
else: else:
return 1 return 1
if args.phase in ('all', 'archive') and not ArchiveChecker().check(repository, repair=args.repair): if not args.repo_only and not ArchiveChecker().check(repository, repair=args.repair):
return 1 return 1
return 0 return 0
@ -432,15 +432,14 @@ def run(self, args=None):
help='select encryption method') help='select encryption method')
check_epilog = textwrap.dedent(""" check_epilog = textwrap.dedent("""
The check command verifies the consistency of a repository and corresponding The check command verifies the consistency of a repository and the corresponding
archives. The check is performed in two phases. In the first phase the archives. The underlying repository data files are first checked to detect bit rot
checksums of the underlying repository segment files are verified to detect and other types of damage. After that the consistency and correctness of the archive
bit rot and other types of damage. In the second phase the consistency and metadata is verified.
correctness of the archive metadata is verified.
A specific check phase can be selected using the --phase=repository|archive The archive metadata checks can be time consuming and requires access to the key
option. This can be useful since the "archive" phase can be time consuming file and/or passphrase if encryption is enabled. These checks can be skipped using
and requires access to the key file and/or passphrase if encryption is enabled. the --repository-only option.
""") """)
subparser = subparsers.add_parser('check', parents=[common_parser], subparser = subparsers.add_parser('check', parents=[common_parser],
description=self.do_check.__doc__, description=self.do_check.__doc__,
@ -450,9 +449,12 @@ def run(self, args=None):
subparser.add_argument('repository', metavar='REPOSITORY', subparser.add_argument('repository', metavar='REPOSITORY',
type=location_validator(archive=False), type=location_validator(archive=False),
help='repository to check consistency of') help='repository to check consistency of')
subparser.add_argument('--phase', dest='phase', choices=['repository', 'archive', 'all'], subparser.add_argument('--repository-only', dest='repo_only', action='store_true',
default='all', default=False,
help='which checks to perform (default: all)') help='only perform repository checks')
subparser.add_argument('--archives-only', dest='archives_only', action='store_true',
default=False,
help='only perform archives checks')
subparser.add_argument('--repair', dest='repair', action='store_true', subparser.add_argument('--repair', dest='repair', action='store_true',
default=False, default=False,
help='attempt to repair any inconsistencies found') help='attempt to repair any inconsistencies found')

View file

@ -344,10 +344,10 @@ def test_check_usage(self):
output = self.attic('check', self.repository_location, exit_code=0) output = self.attic('check', self.repository_location, exit_code=0)
self.assert_in('Starting repository check', output) self.assert_in('Starting repository check', output)
self.assert_in('Starting archive consistency check', output) self.assert_in('Starting archive consistency check', output)
output = self.attic('check', '--phase', 'repository', self.repository_location, exit_code=0) output = self.attic('check', '--repository-only', self.repository_location, exit_code=0)
self.assert_in('Starting repository check', output) self.assert_in('Starting repository check', output)
self.assert_not_in('Starting archive consistency check', output) self.assert_not_in('Starting archive consistency check', output)
output = self.attic('check', '--phase', 'archive', self.repository_location, exit_code=0) output = self.attic('check', '--archives-only', self.repository_location, exit_code=0)
self.assert_not_in('Starting repository check', output) self.assert_not_in('Starting repository check', output)
self.assert_in('Starting archive consistency check', output) self.assert_in('Starting archive consistency check', output)