<?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>jonathanjulian.com &#187; MySQL</title>
	<atom:link href="http://jonathanjulian.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanjulian.com</link>
	<description>Ruby, Rails, JavaScript, software development</description>
	<lastBuildDate>Fri, 13 Jan 2012 21:03:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Backup your mysql blog with cron</title>
		<link>http://jonathanjulian.com/2009/12/backup-your-mysql-blog-with-cron/</link>
		<comments>http://jonathanjulian.com/2009/12/backup-your-mysql-blog-with-cron/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 22:46:38 +0000</pubDate>
		<dc:creator>jonathan</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://jonathanjulian.com/?p=124</guid>
		<description><![CDATA[Everyone&#8217;s tweeting about codinghorror&#8216;s data loss today. I&#8217;m not sure exactly why their hosting provider lost their blog, but I&#8217;m prepared if mine ever does. In my case, it&#8217;s easy &#8211; I email myself a dump of the WordPress mysql database nightly. $ crontab -l 0 7 * * *  /usr/bin/mysqldump -u root -psecret --all-databases [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_125" class="wp-caption alignnone" style="width: 439px"><img class="size-full wp-image-125" title="codinghorror" src="http://jonathanjulian.com/wp-content/uploads/2009/12/00000179.png" alt="codinghorror.com loses it's blog to a hosting failure" width="429" height="69" /><p class="wp-caption-text">codinghorror.com loses it&#39;s blog to a hosting failure</p></div>

<p>Everyone&#8217;s <a href="http://twitter.com/bryanl/statuses/6580555281">tweeting</a> about <a href="http://codinghorror.com/">codinghorror</a>&#8216;s data loss today. I&#8217;m not sure exactly why their hosting provider lost their blog, but I&#8217;m prepared if mine ever does. In my case, it&#8217;s easy &#8211; I email myself a dump of the WordPress mysql database nightly.
<pre>$ crontab -l
0 7 * * *  /usr/bin/mysqldump -u root -psecret --all-databases |bzip2 &gt; /tmp/dbbackup.sql.bz &amp;&amp; (printf "\%b" "Subject: db backup for <code>date</code>\nTo: jonathan\n"; /usr/bin/uuencode /tmp/dbbackup.sql.bz all-databases.sql.bz) |/usr/sbin/ssmtp jonathan@example.com</pre>
That command runs once a night, dumping the structure and contents of my mysql database, compresses it, and formats the file as an email attachment and sends it to me using <a href="http://www.linux.com/archive/feature/132006">ssmtp</a>. You can substitute sendmail, or your favorite MTA (Mail Transfer Agent).</p>

<p>Every morning, I hit &#8220;y&#8221; on that message in gmail, and that&#8217;s a fine tradeoff for sleeping soundly.</p>

<p><strong>UPDATE</strong>: the same technique can be used to backup your entire www directory, saving images and site tweaks. This cron task runs once a week, emailing my my entire WordPress install for all sites hosted on this slice.
<pre>15 7 */7 * *  cd /var/www &amp;&amp; tar zcf /tmp/www.tar.gz * &amp;&amp; (printf "\%b" "Subject: www backup for <code>date</code>\nTo: jonathan\n"; /usr/bin/uuencode /tmp/www.tar.gz www.tar.gz) |/usr/sbin/ssmtp jonathan@example.com</pre>
As you can imagine, the files can be uploaded to another host via scp or sent to Amazon S3 instead of emailed.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonathanjulian.com/2009/12/backup-your-mysql-blog-with-cron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

