<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux System Administration and Security &#187; Python</title>
	<atom:link href="http://www.jasonbrown.us/category/scripting/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonbrown.us</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 02:58:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PyMyDB Backup 0.5.1</title>
		<link>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/</link>
		<comments>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 17:49:09 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[PyMyDB]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=133</guid>
		<description><![CDATA[The first version of PyMyDB Backup has been released and is based on Python 2.4.3. This is a Python script that will back up your MySQL databases, calculate the size of the backed up files, tarball and compress the contents, then email the results. To use: Download the EPEL RPM which can be found at: ]]></description>
			<content:encoded><![CDATA[<p>The first version of PyMyDB Backup has been released and is based on Python 2.4.3. This is a Python script that will back up your MySQL databases, calculate the size of the backed up files, tarball and compress the contents, then email the results.</p>
<p>To use:</p>
<ol>
<li>Download the EPEL RPM which can be found at: <a href="http://download.fedora.redhat.com/pub/epel/">http://download.fedora.redhat.com/pub/epel/</a></li>
<li>Install pymydb-0.5.1-1.noarch.rpm which can be found at: <a href="https://github.com/jasonbrown17/PyMyDB">GitHub</a></li>
<ul>
<li>This script creates the necessary directories and user account</li>
</ul>
<li>After installation, there will be two scripts placed in /usr/local/bin which are pymydb.py and setup.py</li>
<li>Run the setup.py script, this will configure the pymydb.py script</li>
<ul>
<li>Logs into the MySQL server</li>
<li>Creates the backup user, sets a password, and gives him select and lock tables privileges</li>
<li>Configures the email settings</li>
</ul>
<li>Change the permissions on the pymydb.py script</li>
<ul>
<li>chown root.pymydb pymydb.py</li>
</ul>
<li>Add the pymydb.py script into cron and make sure to add a password for the system user</li>
</ol>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=PyMyDB+Backup+0.5.1+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D133" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2011/03/pymyd-0-5-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Backup Script</title>
		<link>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/</link>
		<comments>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 04:03:18 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=122</guid>
		<description><![CDATA[I needed a place to host my scripts, so I opened an account on GitHub. If you are unaware of what GitHub is, its a great place to publish code to the public by using Git; they also offer private hosting for a fee. Even if you do not have a need for this I ]]></description>
			<content:encoded><![CDATA[<p>I needed a place to host my scripts, so I opened an account on GitHub. If you are unaware of what GitHub is, its a great place to publish code to the public by using Git; they also offer private hosting for a fee. Even if you do not have a need for this I recommend looking through the site as its a great place to view open source projects.</p>
<p>There are a lot of examples and scripts out on the Internet to automate MySQL backups but not a whole lot written in Python. This was developed to use in a MySQL replication environment and should be run on the slave server. This is an optimal solution as backup&#8217;s can run without affecting production. The script dumps each database individually, calculates the size of the sql backup, tarball them up, and emails a log when its done.</p>
<p>To run this the MySQLdb module must be installed on the server. You should also create a user specifically designed to run backups. You can effectively do this by running:</p>
<blockquote><p><code>grant select, lock tables on *.* to backup@'localhost' identified by 'password';</code></p></blockquote>
<p>The password is stored in base64 format. To encrypt the password for use in the script, run the following command within the Python terminal:</p>
<blockquote><p><code><br />
&gt;&gt;&gt; from base64 import b64encode as encode<br />
&gt;&gt;&gt; encode("password")<br />
'cGFzc3dvcmQ='</code></p></blockquote>
<p>Though this is not the most secure way to encrypt a password to use within a script, it will prevent shoulder surfers.</p>
<p>Here it is, enjoy &#8211; https://github.com/jasonbrown17/MySQL-Backups</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=MySQL+Backup+Script+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D122" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2011/02/python-mysql-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculate Free Space Using Python</title>
		<link>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/</link>
		<comments>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 13:45:10 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=6</guid>
		<description><![CDATA[import os diskSpace = os.statvfs(&#8216;/&#8217;) (diskSpace.f_bavail * diskSpace.f_frsize) / (1024 * 1024)]]></description>
			<content:encoded><![CDATA[<p>import os<br />
diskSpace = os.statvfs(&#8216;/&#8217;)<br />
(diskSpace.f_bavail * diskSpace.f_frsize) / (1024 * 1024)</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Calculate+Free+Space+Using+Python+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D6" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2010/02/calculate-free-space-using-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

