|
@@ -38,99 +38,107 @@ def parse_arguments(*arguments):
|
|
parser = ArgumentParser(
|
|
parser = ArgumentParser(
|
|
description='''
|
|
description='''
|
|
A simple wrapper script for the Borg backup software that creates and prunes backups.
|
|
A simple wrapper script for the Borg backup software that creates and prunes backups.
|
|
- If none of the --prune, --create, or --check options are given, then borgmatic defaults
|
|
|
|
- to all three: prune, create, and check archives.
|
|
|
|
- '''
|
|
|
|
|
|
+ If none of the action options are given, then borgmatic defaults to: prune, create, and
|
|
|
|
+ check archives.
|
|
|
|
+ ''',
|
|
|
|
+ add_help=False,
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
- '-c',
|
|
|
|
- '--config',
|
|
|
|
- nargs='+',
|
|
|
|
- dest='config_paths',
|
|
|
|
- default=config_paths,
|
|
|
|
- help='Configuration filenames or directories, defaults to: {}'.format(
|
|
|
|
- ' '.join(config_paths)
|
|
|
|
- ),
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--excludes',
|
|
|
|
- dest='excludes_filename',
|
|
|
|
- help='Deprecated in favor of exclude_patterns within configuration',
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
|
|
+
|
|
|
|
+ actions_group = parser.add_argument_group('actions')
|
|
|
|
+ actions_group.add_argument(
|
|
'-I', '--init', dest='init', action='store_true', help='Initialize an empty Borg repository'
|
|
'-I', '--init', dest='init', action='store_true', help='Initialize an empty Borg repository'
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
- '-e',
|
|
|
|
- '--encryption',
|
|
|
|
- dest='encryption_mode',
|
|
|
|
- help='Borg repository encryption mode (for use with --init)',
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--append-only',
|
|
|
|
- dest='append_only',
|
|
|
|
- action='store_true',
|
|
|
|
- help='Create an append-only repository (for use with --init)',
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
- '--storage-quota',
|
|
|
|
- dest='storage_quota',
|
|
|
|
- help='Create a repository with a fixed storage quota (for use with --init)',
|
|
|
|
- )
|
|
|
|
- parser.add_argument(
|
|
|
|
|
|
+ actions_group.add_argument(
|
|
'-p',
|
|
'-p',
|
|
'--prune',
|
|
'--prune',
|
|
dest='prune',
|
|
dest='prune',
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Prune archives according to the retention policy',
|
|
help='Prune archives according to the retention policy',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ actions_group.add_argument(
|
|
'-C',
|
|
'-C',
|
|
'--create',
|
|
'--create',
|
|
dest='create',
|
|
dest='create',
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Create archives (actually perform backups)',
|
|
help='Create archives (actually perform backups)',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ actions_group.add_argument(
|
|
'-k', '--check', dest='check', action='store_true', help='Check archives for consistency'
|
|
'-k', '--check', dest='check', action='store_true', help='Check archives for consistency'
|
|
)
|
|
)
|
|
- parser.add_argument('-l', '--list', dest='list', action='store_true', help='List archives')
|
|
|
|
- parser.add_argument(
|
|
|
|
|
|
+ actions_group.add_argument(
|
|
|
|
+ '-l', '--list', dest='list', action='store_true', help='List archives'
|
|
|
|
+ )
|
|
|
|
+ actions_group.add_argument(
|
|
'-i',
|
|
'-i',
|
|
'--info',
|
|
'--info',
|
|
dest='info',
|
|
dest='info',
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Display summary information on archives',
|
|
help='Display summary information on archives',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+
|
|
|
|
+ init_group = parser.add_argument_group('options for --init')
|
|
|
|
+ init_group.add_argument(
|
|
|
|
+ '-e', '--encryption', dest='encryption_mode', help='Borg repository encryption mode'
|
|
|
|
+ )
|
|
|
|
+ init_group.add_argument(
|
|
|
|
+ '--append-only',
|
|
|
|
+ dest='append_only',
|
|
|
|
+ action='store_true',
|
|
|
|
+ help='Create an append-only repository',
|
|
|
|
+ )
|
|
|
|
+ init_group.add_argument(
|
|
|
|
+ '--storage-quota',
|
|
|
|
+ dest='storage_quota',
|
|
|
|
+ help='Create a repository with a fixed storage quota',
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ create_group = parser.add_argument_group('options for --create')
|
|
|
|
+ create_group.add_argument(
|
|
'--progress',
|
|
'--progress',
|
|
dest='progress',
|
|
dest='progress',
|
|
default=False,
|
|
default=False,
|
|
action='store_true',
|
|
action='store_true',
|
|
- help='Display progress with --create option for each file as it is backed up',
|
|
|
|
|
|
+ help='Display progress for each file as it is backed up',
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ common_group = parser.add_argument_group('common options')
|
|
|
|
+ common_group.add_argument(
|
|
|
|
+ '-c',
|
|
|
|
+ '--config',
|
|
|
|
+ nargs='+',
|
|
|
|
+ dest='config_paths',
|
|
|
|
+ default=config_paths,
|
|
|
|
+ help='Configuration filenames or directories, defaults to: {}'.format(
|
|
|
|
+ ' '.join(config_paths)
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ common_group.add_argument(
|
|
|
|
+ '--excludes',
|
|
|
|
+ dest='excludes_filename',
|
|
|
|
+ help='Deprecated in favor of exclude_patterns within configuration',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ common_group.add_argument(
|
|
'--stats',
|
|
'--stats',
|
|
dest='stats',
|
|
dest='stats',
|
|
default=False,
|
|
default=False,
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Display statistics of archive with --create or --prune option',
|
|
help='Display statistics of archive with --create or --prune option',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ common_group.add_argument(
|
|
'--json',
|
|
'--json',
|
|
dest='json',
|
|
dest='json',
|
|
default=False,
|
|
default=False,
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Output results from the --create, --list, or --info options as json',
|
|
help='Output results from the --create, --list, or --info options as json',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ common_group.add_argument(
|
|
'-n',
|
|
'-n',
|
|
'--dry-run',
|
|
'--dry-run',
|
|
dest='dry_run',
|
|
dest='dry_run',
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Go through the motions, but do not actually write to any repositories',
|
|
help='Go through the motions, but do not actually write to any repositories',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ common_group.add_argument(
|
|
'-v',
|
|
'-v',
|
|
'--verbosity',
|
|
'--verbosity',
|
|
type=int,
|
|
type=int,
|
|
@@ -138,13 +146,14 @@ def parse_arguments(*arguments):
|
|
default=0,
|
|
default=0,
|
|
help='Display verbose progress (1 for some, 2 for lots)',
|
|
help='Display verbose progress (1 for some, 2 for lots)',
|
|
)
|
|
)
|
|
- parser.add_argument(
|
|
|
|
|
|
+ common_group.add_argument(
|
|
'--version',
|
|
'--version',
|
|
dest='version',
|
|
dest='version',
|
|
default=False,
|
|
default=False,
|
|
action='store_true',
|
|
action='store_true',
|
|
help='Display installed version number of borgmatic and exit',
|
|
help='Display installed version number of borgmatic and exit',
|
|
)
|
|
)
|
|
|
|
+ common_group.add_argument('--help', action='help', help='Show this help information and exit')
|
|
|
|
|
|
args = parser.parse_args(arguments)
|
|
args = parser.parse_args(arguments)
|
|
|
|
|