示例#1
0
文件: plugin.py 项目: rcleere/holland
 def backup(self):
     if self.dry_run:
         self.dryrun()
         return
     xb_cfg = self.config["xtrabackup"]
     backup_directory = self.target_directory
     tmpdir = util.evaluate_tmpdir(xb_cfg["tmpdir"], backup_directory)
     # innobackupex --tmpdir does not affect xtrabackup
     util.add_xtrabackup_defaults(self.defaults_path, tmpdir=tmpdir)
     args = util.build_xb_args(xb_cfg, backup_directory, self.defaults_path)
     util.execute_pre_command(xb_cfg["pre-command"], backup_directory=backup_directory)
     stderr = self.open_xb_logfile()
     try:
         stdout = self.open_xb_stdout()
         exc = None
         try:
             try:
                 util.run_xtrabackup(args, stdout, stderr)
             except Exception, exc:
                 LOG.info("!! %s", exc)
                 for line in open(join(self.target_directory, "xtrabackup.log"), "r"):
                     LOG.error("    ! %s", line.rstrip())
                 raise
         finally:
             try:
                 stdout.close()
             except IOError, e:
                 LOG.error("Error when closing %s: %s", stdout.name, e)
                 if exc is None:
                     raise
     finally:
         stderr.close()
     if xb_cfg["apply-logs"]:
         util.apply_xtrabackup_logfile(xb_cfg, args[-1])
示例#2
0
    def backup(self):
        """Perform Backup"""
        xtrabackup_version = util.xtrabackup_version()
        binary_xtrabackup = False
        if LooseVersion(xtrabackup_version) > LooseVersion("8.0.0"):
            LOG.debug("Use xtrabackup without innobackupex ")
            binary_xtrabackup = True

        if self.dry_run:
            self.dryrun(binary_xtrabackup)
            return

        xb_cfg = self.config["xtrabackup"]
        backup_directory = self.target_directory
        tmpdir = util.evaluate_tmpdir(xb_cfg["tmpdir"], backup_directory)
        # innobackupex --tmpdir does not affect xtrabackup
        util.add_xtrabackup_defaults(self.defaults_path, tmpdir=tmpdir)
        args = util.build_xb_args(xb_cfg, backup_directory, self.defaults_path,
                                  binary_xtrabackup)
        util.execute_pre_command(xb_cfg["pre-command"],
                                 backup_directory=backup_directory)
        stderr = self.open_xb_logfile()
        try:
            stdout = self.open_xb_stdout()
            exc = None
            try:
                try:
                    util.run_xtrabackup(args, stdout, stderr)
                except Exception as exc:
                    LOG.info("!! %s", exc)
                    for line in open(
                            join(self.target_directory, "xtrabackup.log"),
                            "r"):
                        LOG.error("    ! %s", line.rstrip())
                    raise
            finally:
                try:
                    stdout.close()
                except IOError as ex:
                    LOG.error("Error when closing %s: %s", stdout.name, ex)
                    if exc is None:
                        raise
        finally:
            stderr.close()
        if xb_cfg["apply-logs"]:
            util.apply_xtrabackup_logfile(xb_cfg, backup_directory,
                                          binary_xtrabackup)
示例#3
0
    def backup(self):
        """Perform Backup"""
        xtrabackup_version = util.xtrabackup_version()
        binary_xtrabackup = False
        if LooseVersion(xtrabackup_version) > LooseVersion("8.0.0"):
            LOG.debug("Use xtrabackup without innobackupex ")
            binary_xtrabackup = True

        if self.dry_run:
            self.dryrun(binary_xtrabackup)
            return

        xb_cfg = self.config["xtrabackup"]
        backup_directory = self.target_directory
        tmpdir = util.evaluate_tmpdir(xb_cfg["tmpdir"], backup_directory)
        # innobackupex --tmpdir does not affect xtrabackup
        util.add_xtrabackup_defaults(self.defaults_path, tmpdir=tmpdir)
        args = util.build_xb_args(xb_cfg, backup_directory, self.defaults_path, binary_xtrabackup)
        util.execute_pre_command(xb_cfg["pre-command"], backup_directory=backup_directory)
        stderr = self.open_xb_logfile()
        try:
            stdout = self.open_xb_stdout()
            exc = None
            try:
                try:
                    util.run_xtrabackup(args, stdout, stderr)
                except Exception as exc:
                    LOG.info("!! %s", exc)
                    for line in open(join(self.target_directory, "xtrabackup.log"), "r"):
                        LOG.error("    ! %s", line.rstrip())
                    raise
            finally:
                try:
                    stdout.close()
                except IOError as ex:
                    LOG.error("Error when closing %s: %s", stdout.name, ex)
                    if exc is None:
                        raise
        finally:
            stderr.close()
        if xb_cfg["apply-logs"]:
            util.apply_xtrabackup_logfile(xb_cfg, backup_directory, binary_xtrabackup)
示例#4
0
 def backup(self):
     """Perform Backup"""
     util.xtrabackup_version()
     if self.dry_run:
         self.dryrun()
         return
     xb_cfg = self.config['xtrabackup']
     backup_directory = self.target_directory
     tmpdir = util.evaluate_tmpdir(xb_cfg['tmpdir'], backup_directory)
     # innobackupex --tmpdir does not affect xtrabackup
     util.add_xtrabackup_defaults(self.defaults_path, tmpdir=tmpdir)
     args = util.build_xb_args(xb_cfg, backup_directory, self.defaults_path)
     util.execute_pre_command(xb_cfg['pre-command'],
                              backup_directory=backup_directory)
     stderr = self.open_xb_logfile()
     try:
         stdout = self.open_xb_stdout()
         exc = None
         try:
             try:
                 util.run_xtrabackup(args, stdout, stderr)
             except Exception as exc:
                 LOG.info("!! %s", exc)
                 for line in open(
                         join(self.target_directory, 'xtrabackup.log'),
                         'r'):
                     LOG.error("    ! %s", line.rstrip())
                 raise
         finally:
             try:
                 stdout.close()
             except IOError as ex:
                 LOG.error("Error when closing %s: %s", stdout.name, ex)
                 if exc is None:
                     raise
     finally:
         stderr.close()
     if xb_cfg['apply-logs']:
         util.apply_xtrabackup_logfile(xb_cfg, args[-1])