+ All Categories
Home > Documents > Learning by Experience, Devploying pyxbackup

Learning by Experience, Devploying pyxbackup

Date post: 08-Aug-2015
Category:
Upload: jervin-real
View: 214 times
Download: 7 times
Share this document with a friend
Popular Tags:
26
Learning by Experience, Deploying pyxbackup Jervin Real PyCon.PH 2015
Transcript
Page 1: Learning by Experience, Devploying pyxbackup

Learning by Experience, Deploying pyxbackup

Jervin RealPyCon.PH 2015

Page 2: Learning by Experience, Devploying pyxbackup

pyxbackup

https://github.com/dotmanila/pyxbackup

Page 3: Learning by Experience, Devploying pyxbackup

There was a need

• to manage backups • for non-dbas • portable (GNU/Linux) • set and forget (kind of)

Page 4: Learning by Experience, Devploying pyxbackup

.. then a solution

• xbackup.sh • bash shell script • yes, portable (GNU/Linux) • yes, for non-dbas • yes, it can manage backups • yes, set and forget (kind of)

Page 5: Learning by Experience, Devploying pyxbackup

But!

• becoming difficult to maintain • .. even debug at times • not very flexible i.e. strings

Page 6: Learning by Experience, Devploying pyxbackup

Python!

Page 7: Learning by Experience, Devploying pyxbackup

How do we begin?

Page 8: Learning by Experience, Devploying pyxbackup

How do we begin

• understood, but have not written Python code

• Opportunity! • Contributing to open source • docs.python.org • StackOverflow, really, really :-)

Page 9: Learning by Experience, Devploying pyxbackup

We all set then!

Page 10: Learning by Experience, Devploying pyxbackup

Debugging, containing errors

• catching Exceptions, or throwing one

Page 11: Learning by Experience, Devploying pyxbackup

Debugging, containing errors

• logging and emailing

Page 12: Learning by Experience, Devploying pyxbackup

Debugging, containing errors

• --debug

Page 13: Learning by Experience, Devploying pyxbackup

Options, parameters, config files

• OptionParser • ConfigParser - also used for metadata

Page 14: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• subprocess.Popen

Page 15: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• os.environ, et. al

http://stackoverflow.com/questions/842059/is-there-a-portable-way-to-get-the-current-username-in-python

Page 16: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• lock/pid files

Page 17: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• signal handling

Page 18: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• logging

Page 19: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• exit codes

Page 20: Learning by Experience, Devploying pyxbackup

Interacting with the environment

• subprocess.Popen • os.environ • lock/pid files • signal handling • logging • exit codes

Page 21: Learning by Experience, Devploying pyxbackup

Aiming for portability

• standard modules, except MySQLdb • MySQLdb instead of Connector/Python • limited external dependencies

Page 22: Learning by Experience, Devploying pyxbackup

pyxbackup

https://github.com/dotmanila/pyxbackup

Page 23: Learning by Experience, Devploying pyxbackup

TODOs

• switch to logging module • discard shell=True • using classes (BackupProcess, Storage, Config) • improve documentation • use Multiprocessing async work • unit tests (aside from functional tests) • daemonize from python (binlog-stream) • port to Python 3

Page 24: Learning by Experience, Devploying pyxbackup

Summary

• portable - standard modules, predictable behaviour through signals and exit codes

• easy to use - useful errors and logs, debuggable

• maintainability - in progress :)

Page 25: Learning by Experience, Devploying pyxbackup

.. and yours truly

• Senior MySQL Consultant at Percona

•@dotmanila

• https://github.com/dotmanila

• http://dotmanila.com/blog/

• http://www.percona.com/blog/author/jervin

Page 26: Learning by Experience, Devploying pyxbackup

Questions


Recommended