资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

MySQLinnobackupex全备是指什么-创新互联

下文主要给大家带来MySQL innobackupex全备是指什么,希望这些内容能够带给大家实际用处,这也是我编辑MySQL innobackupex全备是指什么这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。

创新互联公司主营墨脱网站建设的网络公司,主营网站建设方案,app软件开发公司,墨脱h5小程序设计搭建,墨脱网站营销推广欢迎墨脱等地区企业咨询

MySQL innobackupex全备是指什么

MySQL innobackupex 全备

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
# Author:xtrdb.net

import os
import sys
import errno
import time
import logging
import getopt
import shlex
import MySQLdb
from subprocess import PIPE, Popen, STDOUT

db_host = "116.196.xx.16"
db_port = "9036"
db_user = "zyl"
db_passwd = 'g`QnpqD)P>}25B`^l1h)xxxx'
db_name = "mysql"
conf = "/data/mysql/mysql9036/my9036.cnf"
target_dir = "/data/full_back/test_9036_full_{}".format(time.strftime("%Y%m%d"))
pt_xtrabackup = "/usr/bin/innobackupex"

# start logging
logging.basicConfig(
   filename="/tmp/innobackupex.log",
   format="%(asctime)s:%(levelname)s:%(message)s",
   datefmt="%Y-%m-%d %T",
   level=logging.INFO,
)
logging.info("Start backup...")

class Backup(object):
   def __init__(self,db_conf,user,host,passwd,port,bak_dir):
     self.user = db_user
     self.host = db_host
     self.passwd = db_passwd
     self.port = db_port
     if conf == None:
       self.defaults_file = "/etc/my.cnf"
     else:
       self.defaults_file = conf

     self.target_dir = target_dir

   def backup(self):
     command = "{0} --defaults-file={1} --user={2} --password='{3}' --host={4} --port={5} --no-timestamp {6}".format(pt_xtrabackup, self.defaults_file, self.user, self.passwd, self.host, self.port, self.target_dir)
     print(command)
     status = runCommand(command)
     if status == 1:
       return 1

   def applylog(self):
     command = "%s --defaults-file=%s/backup-my.cnf --apply-log  --user=%s --password='%s' --host=%s --port=%s  %s" % (pt_xtrabackup, target_dir,self.user, self.passwd, self.host,self.port, target_dir)
     print(command)
     status = runCommand(command)
     if status == 1:
       return 1
     return 0
def runCommand(command):
   cmd = shlex.split(command)
   logging.debug('Running back command: "' + command + '"')
   proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
   for line in proc.stderr:
     logging.warning(str(line.strip()))

   for line in proc.stdout:
     logging.debug(str(line.strip()))

   proc.wait()

   if proc.returncode != 0:
     logging.critical('Command failed with return code "' + str(proc.returncode) + '"')
   else:
     logging.debug('Command successfully finished with returncode "' + str(proc.returncode) + '"')
     return 0

if __name__ == '__main__':
   t = Backup("defaults_file","db_user","db_passwd","db_host",9036,"target_dir")
   t.backup()
   backup_status = t.applylog()
   if backup_status == 0:
     db_size = os.popen("du -sh %s" %target_dir).read().split("\t")
     logging.info("backup up dbszie: %s" %db_size[0])

   logging.info("End backup")

对于以上关于MySQL innobackupex全备是指什么,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前题目:MySQLinnobackupex全备是指什么-创新互联
分享网址:http://cdkjz.cn/article/copihc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220