Closed gschoenberger closed 7 years ago
OK, maybe deleting it before calling the method is sufficient?
@@ -559,6 +563,7 @@ def main():
# Pass over to function
func_args = dict(args._get_kwargs())
+ del func_args['config']
Will implement for sponsoring 2h.
The following patch works as expected. Be sure to define it's own resources for each backup job!
diff --git a/scripts/backy.py b/scripts/backy.py
index 271ee49..7a19f5c 100644
--- a/scripts/backy.py
+++ b/scripts/backy.py
@@ -368,6 +368,8 @@ def main():
'-m', '--machine-output', action='store_true', default=False)
parser.add_argument(
'-V', '--version', action='store_true', help='Show version')
+ parser.add_argument(
+ '-c', '--config', default=None, help='Use a backup specific config file', type=str)
subparsers = parser.add_subparsers()
@@ -544,8 +546,10 @@ def main():
#console_level = logging.INFO
else:
console_level = logging.INFO
-
- Config = partial(_Config, conf_name='backy')
+ if args.config is not None and args.config != '':
+ Config = partial(_Config, conf_name='backy' + '_' + args.config)
+ else:
+ Config = partial(_Config, conf_name='backy')
config = Config(section='DEFAULTS')
# logging ERROR only when machine output is selected
@@ -559,6 +563,7 @@ def main():
# Pass over to function
func_args = dict(args._get_kwargs())
+ del func_args['config']
del func_args['func']
del func_args['verbose']
del func_args['version']
You are then able to call:
# backy2 -c my_test_vm.cfg initdb
if:
/etc/backy_my_test_vm.cfg
exists.
Nice! If you could create a pull request including documentation changes, that'd be awesome and I could test it. The documentation should also warn of implications when the same logs, locks, process_name or database/datastore are used. Also, I'd not use the jargon of your specific usecase as "Use a backup specific config file". I'd rather not use a help method and call the long argument "--config-file".
Pull request created
I am trying to add a new option to the arg parser:
But I am facing the followting exception:
Unfortunately I do not know were to add the new option, so that the backup method accepts it. THX, Georg