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