def test_load_config_with_ssh_with_excludes_and_includes(self): config = { "target": { "host": "backuphost", "rsync_path": "/backuppath", "use_ssh": True, "ssh_user": "******" }, "source": { "path": "/" }, "excludes": [ "/foo", "/bar" ], "includes": [ "/bar/baz" ] } backup = RsyncExecutor() backup.load_config(config) backup.commandline_builder() self.assertEqual("/usr/bin/env rsync -a --delete --exclude=/foo --exclude=/bar --include=/bar/baz -e \"ssh -l root\" / backuphost:/backuppath", " ".join( backup.cmd_line))
def test_load_config_without_ssh(self): config = { "target": { "host": "backuphost", "rsync_name": "backuppath" }, "source": { "path": "/" } } backup = RsyncExecutor() backup.load_config(config) backup.commandline_builder() self.assertEqual("/usr/bin/env rsync -a --delete / backuphost::backuppath", " ".join(backup.cmd_line))
"-b", "--batch", dest="batch", action="store_true", help="execute in batch mode, without prompts or anything" ) parser.add_argument( "--ignore-lan-check", dest="ignore_lan_check", action="store_true", help="start backup regardless if target is on same lan as client or not", ) parser.add_argument("--no-cleanup", dest="no_cleanup", action="store_true", help="no unmount on failure") parser.add_argument("config", help="path to configuration yaml") args = parser.parse_args() try: config = load_config(args.config) executor = RsyncExecutor() executor.load_config(config) executor.commandline_builder() except ConfigurationException, ex: LOGGER.exception("Failed to parse configuration") sys.exit(1) if not args.ignore_lan_check and executor.should_backup_run() is False: LOGGER.info("Refusing to start backup since target is on another network") sys.exit(0) # TODO: prompt and execute try: executor.set_up() except Exception, ex: LOGGER.exception("Failed to set up")