Add pre/post exec support
This commit is contained in:
parent
4c147219a7
commit
228892b5e7
|
@ -132,6 +132,14 @@ def status(profile, conf):
|
||||||
return SyncStatus.DATA_MISSING
|
return SyncStatus.DATA_MISSING
|
||||||
|
|
||||||
|
|
||||||
|
def shell_exec(cmd, workdir='/tmp/'):
|
||||||
|
"""
|
||||||
|
Execute a command in shell, wait for exit.
|
||||||
|
"""
|
||||||
|
print("Calling: {}".format(cmd))
|
||||||
|
subprocess.Popen(cmd, shell=True, cwd=workdir).wait()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
Excepts a config file at /etc/datadb.ini. Example:
|
Excepts a config file at /etc/datadb.ini. Example:
|
||||||
|
@ -206,10 +214,22 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.mode == 'restore':
|
if args.mode == 'restore':
|
||||||
|
if args.restore_preexec:
|
||||||
|
shell_exec(args.restore_preexec)
|
||||||
|
|
||||||
restore(args.profile, config[args.profile], force=args.force)
|
restore(args.profile, config[args.profile], force=args.force)
|
||||||
|
|
||||||
|
if args.restore_postexec:
|
||||||
|
shell_exec(args.restore_postexec)
|
||||||
|
|
||||||
elif args.mode == 'backup':
|
elif args.mode == 'backup':
|
||||||
|
if args.export_preexec:
|
||||||
|
shell_exec(args.export_preexec)
|
||||||
|
|
||||||
backup(args.profile, config[args.profile])
|
backup(args.profile, config[args.profile])
|
||||||
|
|
||||||
|
if args.export_postexec:
|
||||||
|
shell_exec(args.export_postexec)
|
||||||
|
|
||||||
elif args.mode == 'status':
|
elif args.mode == 'status':
|
||||||
info = status(args.profile, config[args.profile])
|
info = status(args.profile, config[args.profile])
|
||||||
|
|
Loading…
Reference in New Issue