def main(ctx, cfg, debug, config, version): """ Main entry point :param ctx: context (See Click docs (http://click.pocoo.org/6/) for explanation) :param cfg: instance of ConfigParser :type cfg: ConfigParser.ConfigParser :param debug: if True enabled debug logging :type debug: bool :param config: path to configuration file :type config: str :param version: If True print version string :type version: bool """ if not ctx.invoked_subcommand: if version: print(__version__) exit(0) else: print(ctx.get_help()) exit(-1) setup_logging(LOG, debug=debug) if os.path.exists(config): cfg.read(config) else: LOG.warning("Config file %s doesn't exist", config)
def main( ctx, debug, # pylint: disable=too-many-arguments config, version, xtrabackup_binary, xbstream_binary): """ Main entry point :param ctx: context (See Click docs (http://click.pocoo.org/6/) for explanation) :param debug: if True enabled debug logging :type debug: bool :param config: path to configuration file :type config: str :param version: If True print version string :type version: bool :param xtrabackup_binary: Path to xtrabackup binary. :type xtrabackup_binary: str :param xbstream_binary: Path to xbstream binary. :type xbstream_binary: str """ if not ctx.invoked_subcommand: if version: print(__version__) exit(0) else: print(ctx.get_help()) exit(-1) setup_logging(LOG, debug=debug) if os.path.exists(config): ctx.obj = {'twindb_config': TwinDBBackupConfig(config_file=config)} if xtrabackup_binary is not None: ctx.obj['twindb_config'].mysql.xtrabackup_binary = \ xtrabackup_binary if xbstream_binary is not None: ctx.obj['twindb_config'].mysql.xbstream_binary = \ xbstream_binary else: LOG.warning("Config file %s doesn't exist", config) exit(os.EX_CONFIG)
def main(ctx, cfg, debug, # pylint: disable=too-many-arguments config, version, xtrabackup_binary=XTRABACKUP_BINARY, xbstream_binary=XBSTREAM_BINARY): """ Main entry point :param ctx: context (See Click docs (http://click.pocoo.org/6/) for explanation) :param cfg: instance of ConfigParser :type cfg: ConfigParser.ConfigParser :param debug: if True enabled debug logging :type debug: bool :param config: path to configuration file :type config: str :param version: If True print version string :type version: bool :param xtrabackup_binary: Path to xtrabackup binary. :type xtrabackup_binary: str :param xbstream_binary: Path to xbstream binary. :type xbstream_binary: str """ if not ctx.invoked_subcommand: if version: print(__version__) exit(0) else: print(ctx.get_help()) exit(-1) setup_logging(LOG, debug=debug) if os.path.exists(config): cfg.read(config) try: cfg.set('mysql', 'xtrabackup_binary', xtrabackup_binary) cfg.set('mysql', 'xbstream_binary', xbstream_binary) except NoSectionError: # if there is no mysql section, we will not backup mysql pass else: LOG.warning("Config file %s doesn't exist", config)
def main(ctx, debug, # pylint: disable=too-many-arguments config, version, xtrabackup_binary, xbstream_binary): """ Main entry point :param ctx: context (See Click docs (http://click.pocoo.org/6/) for explanation) :param debug: if True enabled debug logging :type debug: bool :param config: path to configuration file :type config: str :param version: If True print version string :type version: bool :param xtrabackup_binary: Path to xtrabackup binary. :type xtrabackup_binary: str :param xbstream_binary: Path to xbstream binary. :type xbstream_binary: str """ if not ctx.invoked_subcommand: if version: print(__version__) exit(0) else: print(ctx.get_help()) exit(-1) setup_logging(LOG, debug=debug) if os.path.exists(config): ctx.obj = { 'twindb_config': TwinDBBackupConfig(config_file=config) } if xtrabackup_binary is not None: ctx.obj['twindb_config'].mysql.xtrabackup_binary = \ xtrabackup_binary if xbstream_binary is not None: ctx.obj['twindb_config'].mysql.xbstream_binary = \ xbstream_binary else: LOG.warning("Config file %s doesn't exist", config)
import docker import os import pytest import time from docker.errors import DockerException, APIError from docker.types import IPAMPool, IPAMConfig from twindb_backup import setup_logging, LOG NODE_IMAGE = 'centos:centos6' NETWORK_NAME = 'test_network' setup_logging(LOG, debug=True) @pytest.fixture def docker_client(): for _ in xrange(5): try: return docker.DockerClient(version="auto") except DockerException as err: LOG.error(err) time.sleep(5) raise DockerException('Failed to get a docker client') # noinspection PyShadowingNames @pytest.fixture def node_image(docker_client): docker_client.api.pull(NODE_IMAGE)
import pytest from twindb_backup import setup_logging, LOG setup_logging(LOG, debug=True) @pytest.fixture def status_raw_content(): """ Return raw content of status Status is: { "hourly": { "master1/hourly/mysql/mysql-2018-03-28_04_11_16.xbstream.gz": { "backup_finished": 1522210295, "binlog": "mysql-bin.000001", "parent": "master1/daily/mysql/mysql-2018-03-28_04_09_53.xbstream.gz", "lsn": 19903207, "galera": false, "config": [ { "/etc/my.cnf": "W215c3FsZF0KZGF0YWRpcj0vdmFyL2xpYi9teXNxbApzb2NrZXQ9L3Zhci9saWIvbXlzcWwvbXlzcWwuc29jawp1c2VyPW15c3FsCiMgRGlzYWJsaW5nIHN5bWJvbGljLWxpbmtzIGlzIHJlY29tbWVuZGVkIHRvIHByZXZlbnQgYXNzb3J0ZWQgc2VjdXJpdHkgcmlza3MKc3ltYm9saWMtbGlua3M9MAoKc2VydmVyX2lkPTEwMApndGlkX21vZGU9T04KbG9nLWJpbj1teXNxbC1iaW4KbG9nLXNsYXZlLXVwZGF0ZXMKZW5mb3JjZS1ndGlkLWNvbnNpc3RlbmN5CgpbbXlzcWxkX3NhZmVdCmxvZy1lcnJvcj0vdmFyL2xvZy9teXNxbGQubG9nCnBpZC1maWxlPS92YXIvcnVuL215c3FsZC9teXNxbGQucGlkCg==" } ], "backup_started": 1522210276, "position": 46855, "type": "incremental", "wsrep_provider_version": null } },