From 42c0bf059777c9bdbe7c1305ad02118c99e43037 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Tue, 23 Apr 2019 23:17:42 -0700 Subject: [PATCH] Add provisions for resolving a remote host --- bin/backup | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/backup b/bin/backup index cd3a9bf..ab8fecc 100644 --- a/bin/backup +++ b/bin/backup @@ -12,6 +12,7 @@ Command-Line Arguments --debug show debug messages -n, --name name to give to the backup snapshot -p, --port port that ssh on the destination is listening on +-r, --remote-host address/alias of remote machine to use -s, --run-post-sync run sync syscall after backup -u, --umask umask value to use while running backup process -v, --verbose show info messages @@ -93,6 +94,12 @@ def parse_cmdline_arguments(**kwargs): default=22, help="port that ssh on the destination is listening on", ) + parser.add_argument( + "-r", + "--remote-host", + default=None, + help="address/alias of remote machine to use", + ) parser.add_argument( "-s", "--run-post-sync", @@ -118,9 +125,15 @@ def parse_cmdline_arguments(**kwargs): if __name__ == "__main__": args = parse_cmdline_arguments() + dest = ( + args.repository + if args.remote_host is None + else f"{args.remote_host}@{os.getlogin()}:{args.port}{args.repository}" + ) + try: parsed_config = config.parse_configfile() - repo = Repository(args.repository) + repo = Repository(dest) except PermissionError as e: syslog.critical(e) exit(E_PERMISSION)