M
MMZ
I am trying to backup database on CentOS linux server,I'm getting error when running the following script. anyone can help?
#!/usr/bin/env python
import ConfigParser
import os
import time
config = ConfigParser.ConfigParser()
config.read("~/my.cnf")
username = config.get('client', 'mmz')
password = config.get('client', 'pass1')
hostname = config.get('client', 'localhost')
filestamp = time.strftime('%Y-%m-%d')
# Get a list of databases with :
Database_list_command="mysql -u %s -p%s -h %s --silent -N -e 'show databases'" % (username, password, hostname)
for database in os.popen(database_list_command).readlines():
database = database.strip()
if database == 'information_schema':
continue
if database == 'db_dev':
continue
filename = "/backups/mysql/%s-%s.sql" % (database, filestamp)
os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" % (username, password, hostname, database, filename))
.............Error..........
Traceback (most recent call last):
File "./backup.py", line 8, in ?
username = config.get('client', 'mmz')
File "/usr/lib/python2.4/ConfigParser.py", line 511, in get
raise NoSectionError(section)
#!/usr/bin/env python
import ConfigParser
import os
import time
config = ConfigParser.ConfigParser()
config.read("~/my.cnf")
username = config.get('client', 'mmz')
password = config.get('client', 'pass1')
hostname = config.get('client', 'localhost')
filestamp = time.strftime('%Y-%m-%d')
# Get a list of databases with :
Database_list_command="mysql -u %s -p%s -h %s --silent -N -e 'show databases'" % (username, password, hostname)
for database in os.popen(database_list_command).readlines():
database = database.strip()
if database == 'information_schema':
continue
if database == 'db_dev':
continue
filename = "/backups/mysql/%s-%s.sql" % (database, filestamp)
os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" % (username, password, hostname, database, filename))
.............Error..........
Traceback (most recent call last):
File "./backup.py", line 8, in ?
username = config.get('client', 'mmz')
File "/usr/lib/python2.4/ConfigParser.py", line 511, in get
raise NoSectionError(section)