Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does MySQL innobackupex mean?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following mainly brings you what MySQL innobackupex is all about. I hope these contents can bring you practical use, which is also the main purpose of this article that I edit what MySQL innobackupex is all about. All right, don't talk too much nonsense, let's just read the following.

MySQL innobackupex complete

#! / usr/local/bin/python3#-*-coding: utf-8-*-# Author:xtrdb.netimport osimport sysimport errnoimport timeimport loggingimport getoptimport shleximport MySQLdbfrom subprocess import PIPE, Popen STDOUTdb_host = "116.196.xx.16" db_port = "9036" db_user = "zyl" db_passwd = 'g`QnpqD) P >} 25B`^ 1h) 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 logginglogging.basicConfig (filename= "/ tmp/innobackupex.log") Format= "% (asctime) class Backup% (levelname) SV% (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 0def 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 returncode "' + str (proc.returncode) +'") else: logging.debug ('Command successfully finished with returncode "' + Str (proc.returncode) +'") return 0if _ _ 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")

Do you think it is very helpful to know what MySQL innobackupex is all about above? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report