
<?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>Bryce McDonnell &#124;&#124; Freelance Web Application Developer &#187; technology</title>
	<atom:link href="http://www.brycemcdonnell.com/skills-and-expert-groups/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brycemcdonnell.com</link>
	<description>bryce mcdonnell is a freelance web application developer specializing in PHP, Ruby on Rails and MySQL</description>
	<lastBuildDate>Fri, 26 Feb 2010 18:18:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Backing Up Data To Git Securely: Part-1 &#8211; Create the Database User</title>
		<link>http://www.brycemcdonnell.com/2008/12/backing-up-data-to-git-securely-part-1-create-the-database-user/</link>
		<comments>http://www.brycemcdonnell.com/2008/12/backing-up-data-to-git-securely-part-1-create-the-database-user/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 23:54:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Stuff I'm Working On]]></category>
		<category><![CDATA[backing up to git]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://blog.brycemcdonnell.com/?p=70</guid>
		<description><![CDATA[In my backup script I previously posted, we begin by dumping the entire contents of the database to a file. This is not necessarily a good idea and there may be better ways to backup your data. However, the total size of my database is only a few MBs so it isn&#8217;t worth the hassle [...]]]></description>
			<content:encoded><![CDATA[<p>In my backup script I previously posted, we begin by dumping the entire contents of the database to a file. This is not necessarily a good idea and there may be better ways to backup your data. However, the total size of my database is only a few MBs so it isn&#8217;t worth the hassle of creating a master-slave setup.</p>
<p>The goal is to dump the database to the filesystem, add it to the tar file, encrypt it and then delete the clear text version of the file.</p>
<p>Security considerations abound. In a nutshell however, it is important not to publish any unencrypted database dump anywhere. Dump files can be searched on easily by Google and if you house even a morsel of private user data, you&#8217;ll be in trouble very quickly if it&#8217;s not encrypted.</p>
<p>Getting started, the MySQL command to dump a database is:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"> mysqldump <span style="color: #66cc66;">-</span>u user <span style="color: #66cc66;">-</span>psupersecret <span style="color: #808080; font-style: italic;">--all-databases &amp;gt; /some/dir/backupsql.sql</span></pre></div></div>

<p>-p will prompt for a password</p>
<p>-all-databases will dump every database you have running on the mysql instance. If you want a specific database, replace &#8211;all-databases with your_db_name</p>
<p>This command pushes the output of the mysqldump command to a file on the filesystem.</p>
<p>Since I don&#8217;t want my cron job to be prompted for a user&#8217;s password when dumping the db, I have created a special backup user with only enough permissions to read the tables, and write their contents to a file. You can create such a user by running the following command inside a mysql prompt:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">SELECT</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">LOCK</span> <span style="color: #993333; font-weight: bold;">TABLES</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">*.*</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'backup'</span>@<span style="color: #ff0000;">'localhost'</span>
<span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'supersecret'</span></pre></div></div>

<p>Make sure to flush privileges after creating users. There&#8217;s not much more frusterating than trying to figure out why that script didn&#8217;t work.</p>
<p>One security consideration is that if you were to run the ps command while the dump script is running, it will expose the username and password of the backup user potentially allowing other users of the system to make select statements to databases they otherwise shouldn&#8217;t be on.</p>
<p>By limiting the backup user access only from the localhost, this eliminates the possibility of someone else dumping your database from some other host; the user must be logged into the box the database resides on.</p>
<p>At the conclusion of this script, we will have all the database data and structure backed up to a file on the filesystem. In the next post, I&#8217;ll explain how to add this data to a tar archive and then encrypt the whole mess.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brycemcdonnell.com/2008/12/backing-up-data-to-git-securely-part-1-create-the-database-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Securely Backup Your Data Offsite Using Git, OpenSSL and Basic Linux Commands</title>
		<link>http://www.brycemcdonnell.com/2008/12/howto-securely-backup-your-data-offsite-using-git-openssl-and-basic-linux-commands/</link>
		<comments>http://www.brycemcdonnell.com/2008/12/howto-securely-backup-your-data-offsite-using-git-openssl-and-basic-linux-commands/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:15:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Stuff I'm Working On]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://blog.brycemcdonnell.com/?p=69</guid>
		<description><![CDATA[I am becoming a better systems administrator every day secondary to my work  as a ruby on rails and PHP developer. As a very small development shop I have very limited resources to perform the backup and recovery policies bigger shops and huge enterprises employ.
However, after just a morning of futzing with a few [...]]]></description>
			<content:encoded><![CDATA[<p>I am becoming a better systems administrator every day secondary to<a href="http://www.brycemcdonnell.com"> my work </a> as a <a href="http://www.rubyonrails.org">ruby on rails</a> and <a href="http://www.php.net">PHP</a> developer. As a very small development shop I have very limited resources to perform the backup and recovery policies bigger shops and huge enterprises employ.</p>
<p>However, after just a morning of futzing with a few key linux commands and better utilizing a service I already back up my source code to (<a href="http://www.github.com">www.github.com</a>) I have a found a robust and secure way to handle automated, off-site, redundant backups in a way that will let me compete with some bigger shops. I&#8217;ve posted the code below so I hope you will find it useful. Over the next few posts, I&#8217;ll unpack what I&#8217;ve written and the philosophy behind it.</p>
<p>A few things bothered me in the way I was doing traditional backups:</p>
<ol>
<li>I knew I had to get them off-site, but actually finding time to get off-site (to a secure location) wasn&#8217;t happening.</li>
<li>The backup had to be absolutely secure. My clients&#8217; source code is too precious and leakage too damaging to make even one mistake with security breach</li>
<li>Had to be simple and automated. I usually have 10 other things I need to do at the same time. I didn&#8217;t want backups to be number 11.</li>
<li>Small file size. Again, being a small dev shop, I didn&#8217;t want to put a lot of cost into storage of incremental backups</li>
<li>Incremental backups were key since I don&#8217;t want to go to all this trouble only to restore a copy of the bad data I was trying to replace. If I a problem isn&#8217;t made known until after the next set of backups are made, I&#8217;d be overwriting bad data with bad data; better to restore to the point before the problem happened.</li>
</ol>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">#!/usr/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#backupdb</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;======================================&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;backing up database&quot;</span>
mysqldump <span style="color: #660033;">-u</span> backup <span style="color: #660033;">--all-databases</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>alldatabases.sql
&nbsp;
<span style="color: #666666; font-style: italic;">#tar and compress the directories really hacky and should either make a file for exclusions or just get rid of the crap</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-czvvf</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bkp<span style="color: #000000; font-weight: bold;">/</span>websqlbkp.tar.gz <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>alldatabases.sql <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/*</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#encrypt that mug and then remove the decrypted file</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;encrypting backup&quot;</span>
openssl des3 <span style="color: #660033;">-salt</span> <span style="color: #660033;">-k</span> supersecret \
        <span style="color: #660033;">-in</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bkp<span style="color: #000000; font-weight: bold;">/</span>websqlbkp.tar.gz \
        <span style="color: #660033;">-out</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bkp<span style="color: #000000; font-weight: bold;">/</span>websqlbkpencrypted.tar.gz
&nbsp;
<span style="color: #666666; font-style: italic;">#cleanup files I don't want people to see</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;cleaning up files&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bkp<span style="color: #000000; font-weight: bold;">/</span>websqlbkp.tar.gz
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>alldatabasesl.sql
&nbsp;
<span style="color: #666666; font-style: italic;">#update the git repo</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;committing to git <span style="color: #780078;">`date`</span> &quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bkp<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;adding to git&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git add .
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;commiting git&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;commiting backup on <span style="color: #780078;">`date`</span>&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;pushing to github&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git push origin production</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.brycemcdonnell.com/2008/12/howto-securely-backup-your-data-offsite-using-git-openssl-and-basic-linux-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Suitable For Consumer?</title>
		<link>http://www.brycemcdonnell.com/2008/12/linux-suitable-for-consumer/</link>
		<comments>http://www.brycemcdonnell.com/2008/12/linux-suitable-for-consumer/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 08:46:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[business/entrepreneurship]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.brycemcdonnell.com/?p=68</guid>
		<description><![CDATA[I recently read this article at FastCompany&#8217;s website about Linux: the open source, freely available operating system. While it technically competes with Windows and Mac OS X, most users have probably never heard of it. Most data center admins probably couldn&#8217;t live without it. It has a commanding lead in the enterprise hosting space and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read <a href="http://www.fastcompany.com/blog/chris-dannen/techwatch/2009-year-linux-revolution" target="_blank">this article</a> at<a href="http://www.fastcompany.com"> FastCompany&#8217;s</a> website about Linux: the open source, freely available operating system. While it technically competes with Windows and Mac OS X, most users have probably never heard of it. Most data center admins probably couldn&#8217;t live without it. It has a commanding lead in the enterprise hosting space and is responsible for hosting most of the websites on the Internet today. This website, for example, is hosted on a Linux box somewhere in Texas.</p>
<p>The article was profound in explaining Linux&#8217;s potential power play in the netbook arena; netbooks are small low power laptops. They&#8217;re great for surfing the web, doing emails and many other normal, everyday, tasks. Their low power makes them very affordable but has a major shortcoming when it comes to loading an operating system. Without a lot of memory (Ram) or hard drive space, large operating systems with many background processes would cripple the tiny netbook and render them useless.</p>
<p><span id="more-68"></span></p>
<p>Enter Linux. Linux is a highly configurable dream of an operating system that technologists love to play with. Because of its configurability, it&#8217;s a perfect candidate to run on a netbook. Processes that are never used can be shut off automatically. Shutting down processes means 1) more memory to do web surfing 2) more processor cycles for web surfing and 3) less space taken up on the hard drive.</p>
<p>Another very important consideration is spyware/malware. Linux is a very secure system by its very nature. The kernel (the brains of the OS) is more protected by its very design. Because of its seemingly insignificant market penetration, spammers and malware developers don&#8217;t have any incentive to develop their bugs for this OS. Linux wins again.</p>
<p>Finally, slapping Linux on the netbook follows a bigger trend in the commodization of hardware. Computers are getting cheaper and cheaper as business processes become more efficient and components become less expensive. The operating system has become a bigger slice of the total purchase price of a system. As hardware continues to become more of a commodity, vendors like <a href="http://www.ibm.com">IBM</a>, <a href="http://www.hp.com">HP</a> and <a href="http://www.dell.com">DELL</a> will look for ways to jettison the proportionately higher cost of the OS.</p>
<p>As netbooks become more popular, Linux will become more familiar. This familiarity will enhance a seemingly insignificant player in the consumer operating system battle and that could really change the game.</p>
<p>original link:</p>
<p><a href="http://www.fastcompany.com/blog/chris-dannen/techwatch/2009-year-linux-revolution">http://www.fastcompany.com/blog/chris-dannen/techwatch/2009-year-linux-revolution</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brycemcdonnell.com/2008/12/linux-suitable-for-consumer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
