python backup script

Matt Jones matt.walker.jones at gmail.com
Mon May 6 17:08:20 EDT 2013


Why do you have to use that file?  Why can't you copy its contents into a
new file in your working directory and make whatever changes necessary?


Example of the changes your code makes me think you want:

************************
# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock
mmz          = bleh
pass1          = blah
localhost          = bluargh


*Matt Jones*


On Mon, May 6, 2013 at 3:37 PM, MMZ <programmer.toronto at gmail.com> wrote:

> Thanks Matt.
> my.cnf is a readonly file and cannot be changed or modified but do you
> know of a file that stores similar information on CentOS?I think I'm not
> reading from a right file maybe.
>
> On Monday, May 6, 2013 3:46:04 PM UTC-4, Matt Jones wrote:
> > I've never used ConfigParser either, but shouldn't the "[client]"
> section have the options "mmz", "pass1", or "localhost" somewhere?  Do you
> need to add them to that file?
> >
> >
> >
> >
> > Matt Jones
> >
> >
> >
> > On Mon, May 6, 2013 at 2:20 PM, MMZ <programme... at gmail.com> wrote:
> >
> >
> > On Monday, May 6, 2013 3:11:33 PM UTC-4, Jerry Hill wrote:
> >
> >
> > > On Mon, May 6, 2013 at 3:01 PM, MMZ <programme... at gmail.com> wrote:
> >
> > >
> >
> > >
> >
> > >
> >
> > > I am trying to backup database on CentOS linux server,I'm getting
> error when running the following script. anyone can help?
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> >
> > > 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)
> >
> > >
> >
> > >
> >
> > >
> >
> >
> > > I've never used ConfigParser, but that
> >
> > >
> >
> > > error message looks pretty simple to interpret.  You've set up a
> ConfigParser object, told it to read in ~/my.cnf, the asked for the value
> of section 'client', option 'mmz'.  The error indicates that your config
> files doesn't have a section named 'client'.
> >
> >
> >
> > >
> >
> > >
> >
> > >
> >
> > > What is the content of your ~/my.cnf file?
> >
> > >
> >
> > > --
> >
> > >
> >
> > >
> >
> > > Jerry
> >
> >
> >
> > Thank you for helping Jerry. Actually I found this script for debian but
> I want to use it for CentOS server so I replaced /etc/mysql/debian.cnf with
> ~/my.cnf
> >
> > the file content is:
> >
> >
> >
> >  Example MySQL config file for medium systems.
> >
> > #
> >
> > # This is for a system with little memory (32M - 64M) where MySQL plays
> >
> > # an important part, or systems up to 128M where MySQL is used together
> with
> >
> > # other programs (such as a web server)
> >
> > #
> >
> > # MySQL programs look for option files in a set of
> >
> > # locations which depend on the deployment platform.
> >
> > # You can copy this option file to one of those
> >
> > # locations. For information about these locations, see:
> >
> > # http://dev.mysql.com/doc/mysql/en/option-files.html
> >
> > #
> >
> > # In this file, you can use all long options that a program supports.
> >
> > # If you want to know which options a program supports, run the program
> >
> > # with the "--help" option.
> >
> >
> >
> > # The following options will be passed to all MySQL clients
> >
> > [client]
> >
> > #password       = your_password
> >
> > port            = 3306
> >
> > socket          = /tmp/mysql.sock
> >
> >
> >
> > # Here follows entries for some specific programs
> >
> >
> >
> > # The MySQL server
> >
> > [mysqld]
> >
> > port            = 3306
> >
> > socket          = /tmp/mysql.sock
> >
> > skip-locking
> >
> > key_buffer_size = 16M
> >
> > max_allowed_packet = 1M
> >
> > table_open_cache = 64
> >
> > sort_buffer_size = 512K
> >
> > net_buffer_length = 8K
> >
> > read_buffer_size = 256K
> >
> > read_rnd_buffer_size = 512K
> >
> > myisam_sort_buffer_size = 8M
> >
> >
> >
> > # Don't listen on a TCP/IP port at all. This can be a security
> enhancement,
> >
> > # if all processes that need to connect to mysqld run on the same host.
> >
> > # All interaction with mysqld must be made via Unix sockets or named
> pipes.
> >
> > # Note that using this option without enabling named pipes on Windows
> >
> > # (via the "enable-named-pipe" option) will render mysqld useless!
> >
> > #
> >
> > #skip-networking
> >
> >
> >
> > # Replication Master Server (default)
> >
> > # binary logging is required for replication
> >
> > log-bin=mysql-bin
> >
> >
> >
> > # binary logging format - mixed recommended
> >
> > binlog_format=mixed
> >
> >
> >
> > # required unique id between 1 and 2^32 - 1
> >
> > # defaults to 1 if master-host is not set
> >
> > # but will not function as a master if omitted
> >
> > server-id       = 1
> >
> > --
> >
> > http://mail.python.org/mailman/listinfo/python-list
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130506/80a048e7/attachment.html>


More information about the Python-list mailing list