mirror of https://github.com/borgbackup/borg.git
archiver: more argparse cleanup, redundant options, missing metavars
This commit is contained in:
parent
1932fe8ea9
commit
cbeda1d8e3
|
@ -2491,12 +2491,12 @@ class Archiver:
|
||||||
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
|
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
|
||||||
type=location_validator(archive=False),
|
type=location_validator(archive=False),
|
||||||
help='repository to create')
|
help='repository to create')
|
||||||
subparser.add_argument('-e', '--encryption', dest='encryption', required=True,
|
subparser.add_argument('-e', '--encryption', dest='encryption', required=True, metavar='MODE',
|
||||||
choices=('none', 'keyfile', 'repokey', 'keyfile-blake2', 'repokey-blake2', 'authenticated'),
|
choices=('none', 'keyfile', 'repokey', 'keyfile-blake2', 'repokey-blake2', 'authenticated'),
|
||||||
help='select encryption key mode **(required)**')
|
help='select encryption key mode **(required)**')
|
||||||
subparser.add_argument('--append-only', dest='append_only', action='store_true',
|
subparser.add_argument('--append-only', dest='append_only', action='store_true',
|
||||||
help='create an append-only mode repository')
|
help='create an append-only mode repository')
|
||||||
subparser.add_argument('--storage-quota', dest='storage_quota', default=None,
|
subparser.add_argument('--storage-quota', dest='storage_quota', default=None, metavar='QUOTA',
|
||||||
type=parse_storage_quota,
|
type=parse_storage_quota,
|
||||||
help='Set storage quota of the new repository (e.g. 5G, 1.5T). Default: no quota.')
|
help='Set storage quota of the new repository (e.g. 5G, 1.5T). Default: no quota.')
|
||||||
|
|
||||||
|
@ -2557,20 +2557,15 @@ class Archiver:
|
||||||
type=location_validator(),
|
type=location_validator(),
|
||||||
help='repository or archive to check consistency of')
|
help='repository or archive to check consistency of')
|
||||||
subparser.add_argument('--repository-only', dest='repo_only', action='store_true',
|
subparser.add_argument('--repository-only', dest='repo_only', action='store_true',
|
||||||
default=False,
|
|
||||||
help='only perform repository checks')
|
help='only perform repository checks')
|
||||||
subparser.add_argument('--archives-only', dest='archives_only', action='store_true',
|
subparser.add_argument('--archives-only', dest='archives_only', action='store_true',
|
||||||
default=False,
|
|
||||||
help='only perform archives checks')
|
help='only perform archives checks')
|
||||||
subparser.add_argument('--verify-data', dest='verify_data', action='store_true',
|
subparser.add_argument('--verify-data', dest='verify_data', action='store_true',
|
||||||
default=False,
|
|
||||||
help='perform cryptographic archive data integrity verification '
|
help='perform cryptographic archive data integrity verification '
|
||||||
'(conflicts with ``--repository-only``)')
|
'(conflicts with ``--repository-only``)')
|
||||||
subparser.add_argument('--repair', dest='repair', action='store_true',
|
subparser.add_argument('--repair', dest='repair', action='store_true',
|
||||||
default=False,
|
|
||||||
help='attempt to repair any inconsistencies found')
|
help='attempt to repair any inconsistencies found')
|
||||||
subparser.add_argument('--save-space', dest='save_space', action='store_true',
|
subparser.add_argument('--save-space', dest='save_space', action='store_true',
|
||||||
default=False,
|
|
||||||
help='work slower, but using less space')
|
help='work slower, but using less space')
|
||||||
self.add_archives_filters_args(subparser)
|
self.add_archives_filters_args(subparser)
|
||||||
|
|
||||||
|
@ -2613,10 +2608,8 @@ class Archiver:
|
||||||
subparser.add_argument('path', metavar='PATH', nargs='?', type=str,
|
subparser.add_argument('path', metavar='PATH', nargs='?', type=str,
|
||||||
help='where to store the backup')
|
help='where to store the backup')
|
||||||
subparser.add_argument('--paper', dest='paper', action='store_true',
|
subparser.add_argument('--paper', dest='paper', action='store_true',
|
||||||
default=False,
|
|
||||||
help='Create an export suitable for printing and later type-in')
|
help='Create an export suitable for printing and later type-in')
|
||||||
subparser.add_argument('--qr-html', dest='qr', action='store_true',
|
subparser.add_argument('--qr-html', dest='qr', action='store_true',
|
||||||
default=False,
|
|
||||||
help='Create an html file suitable for printing and later type-in or qr scan')
|
help='Create an html file suitable for printing and later type-in or qr scan')
|
||||||
|
|
||||||
key_import_epilog = process_epilog("""
|
key_import_epilog = process_epilog("""
|
||||||
|
@ -2638,7 +2631,6 @@ class Archiver:
|
||||||
subparser.add_argument('path', metavar='PATH', nargs='?', type=str,
|
subparser.add_argument('path', metavar='PATH', nargs='?', type=str,
|
||||||
help='path to the backup')
|
help='path to the backup')
|
||||||
subparser.add_argument('--paper', dest='paper', action='store_true',
|
subparser.add_argument('--paper', dest='paper', action='store_true',
|
||||||
default=False,
|
|
||||||
help='interactively import from a backup done with ``--paper``')
|
help='interactively import from a backup done with ``--paper``')
|
||||||
|
|
||||||
change_passphrase_epilog = process_epilog("""
|
change_passphrase_epilog = process_epilog("""
|
||||||
|
@ -2790,15 +2782,11 @@ class Archiver:
|
||||||
help='create backup')
|
help='create backup')
|
||||||
subparser.set_defaults(func=self.do_create)
|
subparser.set_defaults(func=self.do_create)
|
||||||
|
|
||||||
subparser.add_argument('-n', '--dry-run', dest='dry_run',
|
subparser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='do not create a backup archive')
|
help='do not create a backup archive')
|
||||||
|
subparser.add_argument('-s', '--stats', dest='stats', action='store_true',
|
||||||
subparser.add_argument('-s', '--stats', dest='stats',
|
|
||||||
action='store_true', default=False,
|
|
||||||
help='print statistics for the created archive')
|
help='print statistics for the created archive')
|
||||||
subparser.add_argument('--list', dest='output_list',
|
subparser.add_argument('--list', dest='output_list', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='output verbose list of items (files, dirs, ...)')
|
help='output verbose list of items (files, dirs, ...)')
|
||||||
subparser.add_argument('--filter', dest='output_filter', metavar='STATUSCHARS',
|
subparser.add_argument('--filter', dest='output_filter', metavar='STATUSCHARS',
|
||||||
help='only display items with the given status characters')
|
help='only display items with the given status characters')
|
||||||
|
@ -2808,47 +2796,38 @@ class Archiver:
|
||||||
help='experimental: do not synchronize the cache. Implies ``--no-files-cache``.')
|
help='experimental: do not synchronize the cache. Implies ``--no-files-cache``.')
|
||||||
|
|
||||||
exclude_group = subparser.add_argument_group('Exclusion options')
|
exclude_group = subparser.add_argument_group('Exclusion options')
|
||||||
exclude_group.add_argument('-e', '--exclude', dest='patterns',
|
exclude_group.add_argument('-e', '--exclude', metavar='PATTERN', dest='patterns',
|
||||||
type=parse_exclude_pattern, action='append',
|
type=parse_exclude_pattern, action='append', help='exclude paths matching PATTERN')
|
||||||
metavar="PATTERN", help='exclude paths matching PATTERN')
|
exclude_group.add_argument('--exclude-from', metavar='EXCLUDEFILE', action=ArgparseExcludeFileAction,
|
||||||
exclude_group.add_argument('--exclude-from', action=ArgparseExcludeFileAction,
|
help='read exclude patterns from EXCLUDEFILE, one per line')
|
||||||
metavar='EXCLUDEFILE', help='read exclude patterns from EXCLUDEFILE, one per line')
|
exclude_group.add_argument('--exclude-caches', dest='exclude_caches', action='store_true',
|
||||||
exclude_group.add_argument('--exclude-caches', dest='exclude_caches',
|
|
||||||
action='store_true', default=False,
|
|
||||||
help='exclude directories that contain a CACHEDIR.TAG file ('
|
help='exclude directories that contain a CACHEDIR.TAG file ('
|
||||||
'http://www.brynosaurus.com/cachedir/spec.html)')
|
'http://www.brynosaurus.com/cachedir/spec.html)')
|
||||||
exclude_group.add_argument('--exclude-if-present', dest='exclude_if_present',
|
exclude_group.add_argument('--exclude-if-present', dest='exclude_if_present', metavar='NAME',
|
||||||
metavar='NAME', action='append', type=str,
|
action='append', type=str,
|
||||||
help='exclude directories that are tagged by containing a filesystem object with '
|
help='exclude directories that are tagged by containing a filesystem object with '
|
||||||
'the given NAME')
|
'the given NAME')
|
||||||
exclude_group.add_argument('--keep-exclude-tags', '--keep-tag-files', dest='keep_exclude_tags',
|
exclude_group.add_argument('--keep-exclude-tags', '--keep-tag-files', dest='keep_exclude_tags',
|
||||||
action='store_true', default=False,
|
action='store_true',
|
||||||
help='if tag objects are specified with ``--exclude-if-present``, '
|
help='if tag objects are specified with ``--exclude-if-present``, '
|
||||||
'don\'t omit the tag objects themselves from the backup archive')
|
'don\'t omit the tag objects themselves from the backup archive')
|
||||||
exclude_group.add_argument('--pattern',
|
exclude_group.add_argument('--pattern', metavar='PATTERN', action=ArgparsePatternAction,
|
||||||
action=ArgparsePatternAction,
|
help='experimental: include/exclude paths matching PATTERN')
|
||||||
metavar="PATTERN", help='experimental: include/exclude paths matching PATTERN')
|
exclude_group.add_argument('--patterns-from', metavar='PATTERNFILE', action=ArgparsePatternFileAction,
|
||||||
exclude_group.add_argument('--patterns-from', action=ArgparsePatternFileAction,
|
help='experimental: read include/exclude patterns from PATTERNFILE, one per line')
|
||||||
metavar='PATTERNFILE', help='experimental: read include/exclude patterns from PATTERNFILE, one per line')
|
|
||||||
|
|
||||||
fs_group = subparser.add_argument_group('Filesystem options')
|
fs_group = subparser.add_argument_group('Filesystem options')
|
||||||
fs_group.add_argument('-x', '--one-file-system', dest='one_file_system',
|
fs_group.add_argument('-x', '--one-file-system', dest='one_file_system', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='stay in the same file system and do not store mount points of other file systems')
|
help='stay in the same file system and do not store mount points of other file systems')
|
||||||
fs_group.add_argument('--numeric-owner', dest='numeric_owner',
|
fs_group.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='only store numeric user and group identifiers')
|
help='only store numeric user and group identifiers')
|
||||||
fs_group.add_argument('--noatime', dest='noatime',
|
fs_group.add_argument('--noatime', dest='noatime', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='do not store atime into archive')
|
help='do not store atime into archive')
|
||||||
fs_group.add_argument('--noctime', dest='noctime',
|
fs_group.add_argument('--noctime', dest='noctime', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='do not store ctime into archive')
|
help='do not store ctime into archive')
|
||||||
fs_group.add_argument('--ignore-inode', dest='ignore_inode',
|
fs_group.add_argument('--ignore-inode', dest='ignore_inode', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='ignore inode data in the file metadata cache used to detect unchanged files.')
|
help='ignore inode data in the file metadata cache used to detect unchanged files.')
|
||||||
fs_group.add_argument('--read-special', dest='read_special',
|
fs_group.add_argument('--read-special', dest='read_special', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='open and read block and char device files as well as FIFOs as if they were '
|
help='open and read block and char device files as well as FIFOs as if they were '
|
||||||
'regular files. Also follows symlinks pointing to these kinds of files.')
|
'regular files. Also follows symlinks pointing to these kinds of files.')
|
||||||
|
|
||||||
|
@ -2860,16 +2839,15 @@ class Archiver:
|
||||||
metavar='TIMESTAMP',
|
metavar='TIMESTAMP',
|
||||||
help='manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format). '
|
help='manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format). '
|
||||||
'alternatively, give a reference file/directory.')
|
'alternatively, give a reference file/directory.')
|
||||||
archive_group.add_argument('-c', '--checkpoint-interval', dest='checkpoint_interval',
|
archive_group.add_argument('-c', '--checkpoint-interval', metavar='SECONDS', dest='checkpoint_interval',
|
||||||
type=int, default=1800, metavar='SECONDS',
|
type=int, default=1800,
|
||||||
help='write checkpoint every SECONDS seconds (Default: 1800)')
|
help='write checkpoint every SECONDS seconds (Default: 1800)')
|
||||||
archive_group.add_argument('--chunker-params', dest='chunker_params',
|
archive_group.add_argument('--chunker-params', metavar='PARAMS', dest='chunker_params',
|
||||||
type=ChunkerParams, default=CHUNKER_PARAMS,
|
type=ChunkerParams, default=CHUNKER_PARAMS,
|
||||||
metavar='PARAMS',
|
|
||||||
help='specify the chunker parameters (CHUNK_MIN_EXP, CHUNK_MAX_EXP, '
|
help='specify the chunker parameters (CHUNK_MIN_EXP, CHUNK_MAX_EXP, '
|
||||||
'HASH_MASK_BITS, HASH_WINDOW_SIZE). default: %d,%d,%d,%d' % CHUNKER_PARAMS)
|
'HASH_MASK_BITS, HASH_WINDOW_SIZE). default: %d,%d,%d,%d' % CHUNKER_PARAMS)
|
||||||
archive_group.add_argument('-C', '--compression', dest='compression',
|
archive_group.add_argument('-C', '--compression', metavar='COMPRESSION', dest='compression',
|
||||||
type=CompressionSpec, default=CompressionSpec('lz4'), metavar='COMPRESSION',
|
type=CompressionSpec, default=CompressionSpec('lz4'),
|
||||||
help='select compression algorithm, see the output of the '
|
help='select compression algorithm, see the output of the '
|
||||||
'"borg help compression" command for details.')
|
'"borg help compression" command for details.')
|
||||||
|
|
||||||
|
@ -2905,32 +2883,28 @@ class Archiver:
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
help='extract archive contents')
|
help='extract archive contents')
|
||||||
subparser.set_defaults(func=self.do_extract)
|
subparser.set_defaults(func=self.do_extract)
|
||||||
subparser.add_argument('--list', dest='output_list',
|
subparser.add_argument('--list', dest='output_list', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='output verbose list of items (files, dirs, ...)')
|
help='output verbose list of items (files, dirs, ...)')
|
||||||
subparser.add_argument('-n', '--dry-run', dest='dry_run',
|
subparser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',
|
||||||
default=False, action='store_true',
|
|
||||||
help='do not actually change any files')
|
help='do not actually change any files')
|
||||||
subparser.add_argument('-e', '--exclude', dest='patterns',
|
subparser.add_argument('-e', '--exclude', metavar='PATTERN', dest='patterns',
|
||||||
type=parse_exclude_pattern, action='append',
|
type=parse_exclude_pattern, action='append',
|
||||||
metavar="PATTERN", help='exclude paths matching PATTERN')
|
help='exclude paths matching PATTERN')
|
||||||
subparser.add_argument('--exclude-from', action=ArgparseExcludeFileAction,
|
subparser.add_argument('--exclude-from', metavar='EXCLUDEFILE', action=ArgparseExcludeFileAction,
|
||||||
metavar='EXCLUDEFILE', help='read exclude patterns from EXCLUDEFILE, one per line')
|
help='read exclude patterns from EXCLUDEFILE, one per line')
|
||||||
subparser.add_argument('--pattern', action=ArgparsePatternAction,
|
subparser.add_argument('--pattern', metavar='PATTERN', action=ArgparsePatternAction,
|
||||||
metavar="PATTERN", help='experimental: include/exclude paths matching PATTERN')
|
help='experimental: include/exclude paths matching PATTERN')
|
||||||
subparser.add_argument('--patterns-from', action=ArgparsePatternFileAction,
|
subparser.add_argument('--patterns-from', metavar='PATTERNFILE', action=ArgparsePatternFileAction,
|
||||||
metavar='PATTERNFILE', help='experimental: read include/exclude patterns from PATTERNFILE, one per line')
|
help='experimental: read include/exclude patterns from PATTERNFILE, one per line')
|
||||||
subparser.add_argument('--numeric-owner', dest='numeric_owner',
|
subparser.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='only obey numeric user and group identifiers')
|
help='only obey numeric user and group identifiers')
|
||||||
subparser.add_argument('--strip-components', dest='strip_components',
|
subparser.add_argument('--strip-components', metavar='NUMBER', dest='strip_components',
|
||||||
type=int, default=0, metavar='NUMBER',
|
type=int, default=0,
|
||||||
help='Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped.')
|
help='Remove the specified number of leading path elements. Pathnames with fewer '
|
||||||
subparser.add_argument('--stdout', dest='stdout',
|
'elements will be silently skipped.')
|
||||||
action='store_true', default=False,
|
subparser.add_argument('--stdout', dest='stdout', action='store_true',
|
||||||
help='write all extracted data to stdout')
|
help='write all extracted data to stdout')
|
||||||
subparser.add_argument('--sparse', dest='sparse',
|
subparser.add_argument('--sparse', dest='sparse', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='create holes in output sparse file from all-zero chunks')
|
help='create holes in output sparse file from all-zero chunks')
|
||||||
subparser.add_argument('location', metavar='ARCHIVE',
|
subparser.add_argument('location', metavar='ARCHIVE',
|
||||||
type=location_validator(archive=True),
|
type=location_validator(archive=True),
|
||||||
|
@ -2981,8 +2955,7 @@ class Archiver:
|
||||||
subparser.set_defaults(func=self.do_export_tar)
|
subparser.set_defaults(func=self.do_export_tar)
|
||||||
subparser.add_argument('--tar-filter', dest='tar_filter', default='auto',
|
subparser.add_argument('--tar-filter', dest='tar_filter', default='auto',
|
||||||
help='filter program to pipe data through')
|
help='filter program to pipe data through')
|
||||||
subparser.add_argument('--list', dest='output_list',
|
subparser.add_argument('--list', dest='output_list', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='output verbose list of items (files, dirs, ...)')
|
help='output verbose list of items (files, dirs, ...)')
|
||||||
subparser.add_argument('-e', '--exclude', dest='patterns',
|
subparser.add_argument('-e', '--exclude', dest='patterns',
|
||||||
type=parse_exclude_pattern, action='append',
|
type=parse_exclude_pattern, action='append',
|
||||||
|
@ -3028,14 +3001,11 @@ class Archiver:
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
help='find differences in archive contents')
|
help='find differences in archive contents')
|
||||||
subparser.set_defaults(func=self.do_diff)
|
subparser.set_defaults(func=self.do_diff)
|
||||||
subparser.add_argument('--numeric-owner', dest='numeric_owner',
|
subparser.add_argument('--numeric-owner', dest='numeric_owner', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='only consider numeric user and group identifiers')
|
help='only consider numeric user and group identifiers')
|
||||||
subparser.add_argument('--same-chunker-params', dest='same_chunker_params',
|
subparser.add_argument('--same-chunker-params', dest='same_chunker_params', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='Override check of chunker parameters.')
|
help='Override check of chunker parameters.')
|
||||||
subparser.add_argument('--sort', dest='sort',
|
subparser.add_argument('--sort', dest='sort', action='store_true',
|
||||||
action='store_true', default=False,
|
|
||||||
help='Sort the output lines by file path.')
|
help='Sort the output lines by file path.')
|
||||||
subparser.add_argument('location', metavar='REPO_ARCHIVE1',
|
subparser.add_argument('location', metavar='REPO_ARCHIVE1',
|
||||||
type=location_validator(archive=True),
|
type=location_validator(archive=True),
|
||||||
|
@ -3053,7 +3023,7 @@ class Archiver:
|
||||||
exclude_group.add_argument('--exclude-from', action=ArgparseExcludeFileAction,
|
exclude_group.add_argument('--exclude-from', action=ArgparseExcludeFileAction,
|
||||||
metavar='EXCLUDEFILE', help='read exclude patterns from EXCLUDEFILE, one per line')
|
metavar='EXCLUDEFILE', help='read exclude patterns from EXCLUDEFILE, one per line')
|
||||||
exclude_group.add_argument('--exclude-caches', dest='exclude_caches',
|
exclude_group.add_argument('--exclude-caches', dest='exclude_caches',
|
||||||
action='store_true', default=False,
|
action='store_true',
|
||||||
help='exclude directories that contain a CACHEDIR.TAG file ('
|
help='exclude directories that contain a CACHEDIR.TAG file ('
|
||||||
'http://www.brynosaurus.com/cachedir/spec.html)')
|
'http://www.brynosaurus.com/cachedir/spec.html)')
|
||||||
exclude_group.add_argument('--exclude-if-present', dest='exclude_if_present',
|
exclude_group.add_argument('--exclude-if-present', dest='exclude_if_present',
|
||||||
|
@ -3061,7 +3031,7 @@ class Archiver:
|
||||||
help='exclude directories that are tagged by containing a filesystem object with '
|
help='exclude directories that are tagged by containing a filesystem object with '
|
||||||
'the given NAME')
|
'the given NAME')
|
||||||
exclude_group.add_argument('--keep-exclude-tags', '--keep-tag-files', dest='keep_exclude_tags',
|
exclude_group.add_argument('--keep-exclude-tags', '--keep-tag-files', dest='keep_exclude_tags',
|
||||||
action='store_true', default=False,
|
action='store_true',
|
||||||
help='if tag objects are specified with ``--exclude-if-present``, '
|
help='if tag objects are specified with ``--exclude-if-present``, '
|
||||||
'don\'t omit the tag objects themselves from the backup archive')
|
'don\'t omit the tag objects themselves from the backup archive')
|
||||||
exclude_group.add_argument('--pattern',
|
exclude_group.add_argument('--pattern',
|
||||||
|
@ -3108,7 +3078,6 @@ class Archiver:
|
||||||
help='force deletion of corrupted archives, '
|
help='force deletion of corrupted archives, '
|
||||||
'use ``--force --force`` in case ``--force`` does not work.')
|
'use ``--force --force`` in case ``--force`` does not work.')
|
||||||
subparser.add_argument('--save-space', dest='save_space', action='store_true',
|
subparser.add_argument('--save-space', dest='save_space', action='store_true',
|
||||||
default=False,
|
|
||||||
help='work slower, but using less space')
|
help='work slower, but using less space')
|
||||||
subparser.add_argument('location', metavar='TARGET', nargs='?', default='',
|
subparser.add_argument('location', metavar='TARGET', nargs='?', default='',
|
||||||
type=location_validator(),
|
type=location_validator(),
|
||||||
|
|
Loading…
Reference in New Issue