<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Rails Coder: Develop &#38; Deploy</title>
	<atom:link href="http://therailscoder.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://therailscoder.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 12 Mar 2009 06:26:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='therailscoder.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Rails Coder: Develop &#38; Deploy</title>
		<link>http://therailscoder.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://therailscoder.wordpress.com/osd.xml" title="The Rails Coder: Develop &#38; Deploy" />
	<atom:link rel='hub' href='http://therailscoder.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Monitor your Rails App&#8217;s Mongrels with GOD</title>
		<link>http://therailscoder.wordpress.com/2008/08/11/monitor-your-rails-apps-mongrels-with-god/</link>
		<comments>http://therailscoder.wordpress.com/2008/08/11/monitor-your-rails-apps-mongrels-with-god/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 09:49:50 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/08/11/monitor-your-rails-apps-mongrels-with-god/</guid>
		<description><![CDATA[Monitoring the mongrels in your rails app is important when your website is in production. Sometimes things can go wrong, and your mongrels can start chewing up increasing amounts of memory and cpu power that could bring your rails app to its knees. So, you need something to keep an eye on them and restart [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=5&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Monitoring the mongrels in your rails app is important when your website is in production. Sometimes things can go wrong, and your mongrels can start chewing up increasing amounts of memory and cpu power that could bring your rails app to its knees. So, you need something to keep an eye on them and restart them when this happens. There are various solutions available to achieve this. The common options are Monit, Munin, or GOD:</p>
<p><strong>Monit</strong>: <a href="http://www.tildeslash.com/monit/" target="_blank">http://www.tildeslash.com/monit/</a></p>
<p><strong>Munin:</strong> <a href="http://munin.projects.linpro.no/" target="_blank">http://munin.projects.linpro.no/</a></p>
<p><strong>GOD:</strong> <a href="http://god.rubyforge.org" target="_blank">http://god.rubyforge.org</a></p>
<p>Of the 3 above solutions, i have found GOD to be the easiest to set up. I will try and outline the steps i took to get things working. I will also show you how i integrate this with Google Apps Mail for email notifications. The details of how to manipulate the GOD configuration are explained in depth on the GOD website, so i will not discuss that here.</p>
<p>My production server is running the following:</p>
<ul>
<li>Rails 2.0.2</li>
<li>Ubuntu Gutsy </li>
<li>nginx 0.5.26</li>
<li>mongrel 1.1.4</li>
<li>mongrel_cluster 1.0.5</li>
<li>god 0.7.8</li>
<li>tlsmail 0.0.1</li>
</ul>
<p><span style="text-decoration:underline;"><strong>Step 1:</strong></span></p>
<p>Install the god gem:</p>
<p><strong>sudo gem install god</strong></p>
<p><span style="text-decoration:underline;"><strong>Step 1a (OPTIONAL):</strong></span></p>
<p>Install the tlsmail gem if you want to use GMail:</p>
<p><strong>sudo gem install tlsmail</strong></p>
<p>You can read more about using GMail in your rails app in my previous blog post:</p>
<p><a href="http://therailscoder.typepad.com/the_rails_coder_ruby_on_r/2008/04/using-gmail-smt.html" target="_blank">http://therailscoder.typepad.com/the_rails_coder_ruby_on_r/2008/04/using-gmail-smt.html</a><strong><br /></strong><br /><span style="text-decoration:underline;"><strong>Step 2:<br /></strong></span><br />Find and edit the init.d script.</p>
<p><strong>cd /etc/init.d<br />ls -l<br />sudo nano /etc/init.d./god</strong></p>
<p>It should look like this:</p>
<p><a href="http://pastie.org/250816" target="_blank">http://pastie.org/250816</a></p>
<p>Run these commands to make the god script executable and allow it to start on a reboot of the server.<br /><strong><br />chmod +x /etc/init.d/god<br />/usr/sbin/update-rc.d god defaults</strong></p>
<p><span style="text-decoration:underline;"><strong>Step 3:<br /></strong></span><br />Create your god config file.</p>
<p><strong>cd /etc<br />sudo nano god.conf</strong></p>
<p>This is basically a configuration taken from the god website, but i had to make some changes to the location of the pid files, make sure you get this right &#8211; otherwise things will not work the way they should (<em>you can also exclude the code from line 60 onwards if you are not using email notifications with GMail)</em>:</p>
<p><a href="http://pastie.org/250821" target="_blank">http://pastie.org/250821</a></p>
<p><span style="text-decoration:underline;"><strong>Step 4:</strong></span></p>
<p>Start god:</p>
<p><strong>sudo /etc/init.d/god start</strong></p>
<p>You should see something like this:</p>
<p style="font-family:Trebuchet MS;"><strong><font class="fixed_width">Sending &#39;load&#39; command</p>
<p>The following tasks were affected:</font></strong></p>
<p style="font-family:Trebuchet MS;"><strong><font class="fixed_width">mydomain-mongrel-8000<br />
<br /> mydomain-mongrel-8001<br />
<br /> mydomain-mongrel-8002<br />
</font></strong></p>
<p><span style="text-decoration:underline;"><strong>Step 5:<br /></strong></span></p>
<p>Check whether your mongrels are being monitored:</p>
<p><strong>sudo god status</strong></p>
<p>You should see something like this:</p>
<p><strong><font class="fixed_width">mydomain-mongrel-8000: up<br />
<br /> mydomain-mongrel-8001: up<br />
<br /> mydomain-mongrel-8002: up<br />
</font></strong></p>
<p>If god is not monitoring your mongrels, you will see this:<span style="text-decoration:underline;"><strong></p>
<p></strong></span><strong><font class="fixed_width" face="Courier, Monospaced">mydomain-mongrel-8000: unmonitored<br />
<br /> mydomain-mongrel-8001: unmonitored<br />
<br /> mydomain-mongrel-8002: unmonitored</font></strong><br /><span style="text-decoration:underline;"><strong><br />Step 6:</strong></span></p>
<p>Now, to really see god in action, i look at the log files:</p>
<p><strong>sudo god log</strong> <strong><font class="fixed_width">mydomain-mongrel-8000<br />
</font></strong><br /><strong>sudo god log</strong> <strong><font class="fixed_width">mydomain-mongrel-8001<br />
</font></strong><br /><strong>sudo god log</strong> <strong><font class="fixed_width">mydomain-mongrel-8002</font></strong></p>
<p>You should start seeing messages like this, which means it is working:</p>
<p><em>INFO: mydomain-mongrel-8000 [ok] process is running (ProcessRunning)<br />INFO: mydomain-mongrel-8000 [ok] memory within bounds [59456kb, 59456kb, 59456kb, 59456kb, 59456kb] (MemoryUsage)<br />INFO: mydomain-mongrel-8000 [ok] cpu within bounds [0.00891569765038892%, 0.00891040849797263%, 0.00890512561731393%, 0.00889984899726403%, 0.00889457862670062%] (CpuUsage)</em></p>
<p><span style="text-decoration:underline;"><strong>Step 7:<br /></strong></span><br />To stop god:</p>
<p><strong>sudo /etc/init.d/god stop<br /></strong><br /><span style="text-decoration:underline;"><strong>Step 8:<br /></strong></span><br />Lastly, I recommend changing the memory or cpu useage to a lower level and then watching the logs to see that god is picking up on this and restarting the mongrels, as well as sending emails!</p>
<p><span style="text-decoration:underline;"><strong>Conclusion</strong></span>:</p>
<p>That&#39;s it, check out the GOD website and Google Group for more info!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=5&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/08/11/monitor-your-rails-apps-mongrels-with-god/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Basic MySQL Terminal Commands</title>
		<link>http://therailscoder.wordpress.com/2008/07/17/basic-mysql-terminal-commands/</link>
		<comments>http://therailscoder.wordpress.com/2008/07/17/basic-mysql-terminal-commands/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 09:28:10 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/07/17/basic-mysql-terminal-commands/</guid>
		<description><![CDATA[To start MySQL monitor; mysql -u root -p Other commands; show databases;use enter_database_name_here;show tables;describe enter_table_name_here;Show data from a particular column in a table; SELECT enter_column_name_here FROM enter_table_name_here;Update the data in a particular column in a table; UPDATE enter_table_name_here SET enter_column_name_here = &#8216;enter_new_value_here&#8217; WHERE id =&#8217;enter_id_here&#8217;;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=6&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration:underline;"><em>To start MySQL monitor;</em></span></p>
<p><strong>mysql -u root -p</strong></p>
<p><span style="text-decoration:underline;"><em>Other commands;</em></span></p>
<p><strong>show databases</strong>;<br /><strong>use</strong> enter_database_name_here;<br /><strong>show</strong> tables;<br /><strong>describe</strong> enter_table_name_here;<br /><span style="text-decoration:underline;"><em><br />Show data from a particular column in a table;</em></span></p>
<p><strong>SELECT</strong> enter_column_name_here <strong>FROM</strong> enter_table_name_here;<br /><span style="text-decoration:underline;"><em><br />Update the data in a particular column in a table;</em></span></p>
<p><strong>UPDATE</strong> enter_table_name_here <strong>SET</strong> enter_column_name_here = &#8216;enter_new_value_here&#8217; <strong>WHERE</strong> id =&#8217;enter_id_here&#8217;;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=6&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/07/17/basic-mysql-terminal-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Internet Explorer on Mac</title>
		<link>http://therailscoder.wordpress.com/2008/07/12/internet-explorer-on-mac/</link>
		<comments>http://therailscoder.wordpress.com/2008/07/12/internet-explorer-on-mac/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 09:24:22 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/07/12/internet-explorer-on-mac/</guid>
		<description><![CDATA[If you&#8217;re designing a website you really have to design for Internet Explorer, as a lot of people still use it. The main versions would be IE6 and IE7, with IE8 not too far away. My method now is to design first for Firefox and Safari. If things look good on these browsers, they are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=7&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re designing a website you really have to design for Internet Explorer, as a lot of people still use it. The main versions would be <strong>IE6</strong> and <strong>IE7</strong>, with <strong>IE8</strong> not too far away.</p>
<p>My method now is to design first for <strong>Firefox</strong> and <strong>Safari</strong>. If things look good on these browsers, they are likely to be good on <strong>Opera</strong> as well. Then, i make tweaks to fit IE7, i&#8217;ve not yet started developing for IE8 as it is still in beta. IE7 has its quirks, but it is not too difficult to get things looking similar or exactly the same as it would on Firefox and Safari. IE6 is another story all together. It is painful trying to get CSS to look the way you want on this browser. IE6 has a number of bugs and &#8216;bug fixes&#8217; or hacks that are well documented on the web.</p>
<p>But having said that, if you want to adjust your website design to fit Internet Explorer whilst on a Mac, without having to move over to a Windows PC &#8211; there are a few options that could make things easier.</p>
<p><span style="text-decoration:underline;"><strong>Option 1:<br /></strong></span><em><br />Use Parallels.</em></p>
<p>http://www.parallels.com</p>
<p>Parallels basically lets you install a version of Windows on your Mac. You can then install and use any Windows software on your Mac. Windows XP is probably a better bet than Windows Vista. The reason being that there are some known issues getting IE6 to work on Vista. If you install XP, you will get IE6 as standard, but you can upgrade to IE7. You can then install the Multiple_IE software which will give you IE versions 3 to 6:</p>
<p>http://tredosoft.com/Multiple_IE</p>
<p>You could probably also use Firefox and get a multiple IE plugin (these plugins need Windows, and won&#8217;t work on Mac Firefox):</p>
<p>https://addons.mozilla.org/en-US/firefox/addon/1419</p>
<p>Parallels costs about US$79.99. </p>
<p><span style="text-decoration:underline;"><strong>Option 2:</strong></span></p>
<p><em>UseVMware Fusion.</em></p>
<p>http://www.vmware.com/products/fusion/</p>
<p>This lets you run a &#8216;Virtual PC&#8217; on your Mac, i don&#8217;t know much about this, but cost is also about US$79.99</p>
<p><span style="text-decoration:underline;"><strong>Option 3:</strong></span></p>
<p><em>Use ie4osx.</em></p>
<p>http://www.kronenberg.org/ies4osx/</p>
<p>This lets you use IE5 to 7. It does not require Parallels or VMware Fusion. It is FREE. And it is dead simple to install. Unforunately it is supposed to be a bit buggy with IE7, but hopefully that will change soon. This is the option i chose as IE6 is what i need to test the most, and is the hardest to code right. </p>
<p>Hope this helps someone.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=7&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/07/12/internet-explorer-on-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Restore a MySQL Database</title>
		<link>http://therailscoder.wordpress.com/2008/06/06/restore-a-mysql-database/</link>
		<comments>http://therailscoder.wordpress.com/2008/06/06/restore-a-mysql-database/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 21:06:47 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/06/06/restore-a-mysql-database/</guid>
		<description><![CDATA[To restore a MySQL database with a backed up *.sql file, enter the following from a command line prompt after moving into the directory in which the *.sql file is in: mysql -u root -p databasename &#60; backupfile.sql That&#8217;s it..<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=8&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To restore a MySQL database with a backed up *.sql file, enter the following from a command line prompt after moving into the directory in which the *.sql file is in:</p>
<div><span style="font-weight:bold;">mysql -u root -p databasename &lt; backupfile.sql</span></div>
<p>
<div>That&#8217;s it..</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=8&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/06/06/restore-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple_Captcha with Restful_Authentication</title>
		<link>http://therailscoder.wordpress.com/2008/04/27/simple_captcha-with-restful_authentication/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/27/simple_captcha-with-restful_authentication/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 13:50:36 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/27/simple_captcha-with-restful_authentication/</guid>
		<description><![CDATA[Enabling Simple_Catpcha verification with Restful_Authentication for new user signups is quite easy. I found the answer on the Restful_Authentication &#8220;bells and whistles&#8221; thread on Rails Forum. The reason i needed this was because i did not want to use email activation for new users, i wanted them to be able to log in straight away, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=9&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Enabling Simple_Catpcha verification with Restful_Authentication for new user signups is quite easy. I found the answer on the Restful_Authentication &#8220;bells and whistles&#8221; thread on Rails Forum. The reason i needed this was because i did not want to use email activation for new users, i wanted them to be able to log in straight away, and i needed some sort of protection against spam bots.</p>
<p>Anyway, add the &#8220;show_simple_captcha&#8221; code to your new user signup form and include the parameter <img src='http://s1.wp.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&gt; &#8216;user&#8217;. Then add the following to the user model &#8211; <strong>models/user.rb</strong>:</p>
<p>apply_simple_captcha      :message =&gt; &#8220;The text does not match the image&#8221;, :add_to_base =&gt; true<br />
attr_accessible :login, :email, :password, :password_confirmation, :identity_url, :profile, <strong>:captcha, :captcha_key</strong></p>
<p>And finally change the <strong>user_controller.rb</strong> create action:</p>
<p>  def create<br />
cookies.delete :auth_token<br />
@user = User.new(params[:user])<br />
if @user.save_with_captcha<br />
#Uncomment to have the user logged in after creating an account &#8211; Not Recommended<br />
#self.current_user = @user<br />
flash[:notice] = &#8220;Thanks for signing up!&#8221;<br />
redirect_to login_path    <br />
else<br />
flash[:error] = &#8220;There was a problem creating your account.&#8221;<br />
render :action =&gt; &#8216;new&#8217;<br />
end<br />
end</p>
<p>That&#8217;s it.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=9&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/27/simple_captcha-with-restful_authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Using GMail SMTP with ActionMailer</title>
		<link>http://therailscoder.wordpress.com/2008/04/27/using-gmail-smtp-with-actionmailer/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/27/using-gmail-smtp-with-actionmailer/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 13:02:28 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/27/using-gmail-smtp-with-actionmailer/</guid>
		<description><![CDATA[There are a number of solutions that have been posted around the net to get Rails&#8217; ActionMailer to talk to GMail, allowing you to send email from your Rails app. From Googling around, it seems that many bloggers have quoted a post from Anatol Pomozov. However, this is now a dead link: http://blog.pomozov.info/posts/how-to-send-actionmailer-mails-to-gmailcom.html Stephen Chu [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=10&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are a number of solutions that have been posted around the net to get Rails&#8217; ActionMailer to talk to GMail, allowing you to send email from your Rails app. From Googling around, it seems that many bloggers have quoted a post from <strong>Anatol Pomozov</strong>. However, this is now a dead link:</p>
<p><u><strong>http://blog.pomozov.info/posts/how-to-send-actionmailer-mails-to-gmailcom.html</strong></u></p>
<p><strong>Stephen Chu</strong> talked about how to use GMail&#8217;s smtp server back in 2006:</p>
<p><u><strong>http://www.stephenchu.com/2006/06/how-to-use-gmail-smtp-server-to-send.html</strong></u></p>
<p>More recently, <strong>Preston Lee</strong> talks about the Anatol Pomozov approach here:</p>
<p><u><strong>http://www.prestonlee.com/archives/63</strong></u></p>
<p>And <strong>Daniel Fischer</strong> explains how to use the action_mailer_tls plugin &#8211; this method is also mentioned in the new <strong>Advanced Rails Recipes</strong> book:</p>
<p><u><strong>http://www.danielfischer.com/2008/01/09/how-to-use-gmail-as-your-mail-server-for-rails/</strong></u></p>
<p>However, there is another far easier solution that was posted originally to my knowledge by <strong>Tim Riendeau</strong>:</p>
<p><u><strong>http://www.wanlord.com/articles/2007/11/29/sending-email-using-actionmailer-and-gmail</strong></u></p>
<p>I will repeat the steps as they worked for me here&#8230;</p>
<p><strong>1. Install the tlsmail gem</strong></p>
<p>sudo gem install tlsmail</p>
<p><strong>2. Add the following to the bottom of your environment.rb</strong></p>
<p>require &#8216;tlsmail&#8217;<br />
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)</p>
<p>ActionMailer::Base.delivery_method = :smtp<br />
ActionMailer::Base.smtp_settings = {<br />
:address =&gt; &#8216;smtp.gmail.com&#8217;,<br />
:tls =&gt; &#8216;true&#8217;,<br />
:port =&gt; 587,<br />
:domain =&gt; &#8216;mydomain.com&#8217;,<br />
:authentication =&gt; :plain,<br />
:user_name =&gt; &#8216;info@mydomain.com&#8217;,<br />
:password =&gt; &#8216;mypassword&#8217;<br />
}</p>
<p><strong>3. To enable errors to show up if the mail does not get delivered, modify your development.rb and production.rb as shown below &#8211; it&#8217;s ok to make this true in devlopment, but i think most people say to set this to false in production:</strong></p>
<p>development.rb<br />
config.action_mailer.raise_delivery_errors = true</p>
<p>production.rb<br />
config.action_mailer.raise_delivery_errors = false</p>
<p><em>And that&#8217;s it!</em></p>
<p><strong>NOTE: &#8220;Timeout::Error (execution expired)&#8221;</strong></p>
<p>I got this message quite a lot when i tried to send emails in development, and no one seems to know why this is the case. But when i switched to production things worked like a breeze. I am developing on a MacBook Pro with Leopard, if you have any idea why this happens please let me know.</p>
<p><strong>NOTE: Internet Service Provider blocking ports</strong></p>
<p>Another point to note is that some ISP&#8217;s block outgoing smtp mail on certain ports, eg port 25. Check with your ISP if they do any port filtering.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=10&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/27/using-gmail-smtp-with-actionmailer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatic MySQL Database Backups to Amazon S3 with S3SYNC</title>
		<link>http://therailscoder.wordpress.com/2008/04/19/automatic-mysql-database-backups-to-amazon-s3-with-s3sync/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/19/automatic-mysql-database-backups-to-amazon-s3-with-s3sync/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 18:26:34 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/19/automatic-mysql-database-backups-to-amazon-s3-with-s3sync/</guid>
		<description><![CDATA[I am running an Ubuntu Gutsy based Slicehost VPS, and have a Macbook Pro development machine. On my server i am logged in as a user with sudo privileges. What i&#8217;d like to document in this blog post is how to create automatic MySQL database backups to Amazon S3 with S3SYNC. Now there are a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=11&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am running an Ubuntu Gutsy based Slicehost VPS, and have a Macbook Pro development machine. On my server i am logged in as a user with sudo privileges. What i&#8217;d like to document in this blog post is how to create automatic MySQL database backups to Amazon S3 with S3SYNC. </p>
<p>Now there are a lot of options available to achieve all this, this is the way that i found easy and that worked for me. To create the automatic mysql database dumps, there is the <strong>automysqlbackup</strong> script available from SourceForge:</p>
<p><u><strong>http://sourceforge.net/projects/automysqlbackup/</strong></u></p>
<p>I downloaded this onto my Macbook Pro and used <strong>&#8216;scp&#8217;</strong> to copy back to my server. I suppose you could use <strong>&#8216;wget&#8217;</strong> directly form the server too if you prefer. You can put the file anywhere on the server you like, i just keep it in my home directory for now (/home/user/) &#8211; but i will move it later. First thing is to rename the file, at the time of writing version 2.5 was available:</p>
<p><strong>sudo mv automysqlbackup.sh.2.5 automysqlbackup.sh</strong></p>
<p>Now create a directory in which you want your backups to go to, and one where the restored backups from S3 will be downloaded to, eg /home/user/mysqlbackups/ and /home/user/mysqlrestores/:</p>
<p><strong>mkdir mysqlbackups</strong><br />
<strong>mkdir mysqlrestores</strong></p>
<p>The automysqlbackup script is of course just one file, and you can open and view it in a text editor. In fact i suggest that you do that next as it has pretty good instructions as to what it does and what parameters you need to add. Move to the directory in which you have the script and open it up, i use the nano editor: </p>
<p><strong>sudo nano automysqlbackup.sh</strong></p>
<p>Basically you need to add the names of your databases, mysql user, and mysql password info. The script will do daily, weekly, and monthly backups of your database into the specified backup folder of your choice &#8211; you can even have emails sent to you! Here is an excerpt:</p>
<p><strong># Username to access the MySQL server e.g. dbuser<br />
USERNAME=root</p>
<p># Username to access the MySQL server e.g. password<br />
PASSWORD=********</p>
<p># Host name (or IP address) of MySQL server e.g localhost<br />
DBHOST=localhost</p>
<p># List of DBNAMES for Daily/Weekly Backup e.g. &#8220;DB1 DB2 DB3&#8243;<br />
DBNAMES=&#8221;therailscoder_production&#8221;</p>
<p># Backup directory location e.g /backups<br />
BACKUPDIR=&#8221;/home/user/mysqlbackups&#8221;</strong></p>
<p>Edit the files with your own settings, then save and exit!</p>
<p>Next edit the permissions on the script to give read, write, and execute permissions to the user, and not to to anyone else.</p>
<p><strong>sudo chmod 700 automysqbackup.sh</strong></p>
<p>You can test the script out manually as follows:</p>
<p><strong>./automysqlbackup.sh</strong></p>
<p>Move to your backups directory and you should see 3 sub-directories &#8211; daily, weekly, and monthly. In the daily directory you will find a gzipped sql file of you database backup! I will talk about how to actually automate this process a little later on&#8230;</p>
<p>Next we need to get the mysql backup&#8217;s over to Amazon S3. If you haven&#8217;t got an S3 account, sign up and get your Access Key ID and Secret Access Key ready:</p>
<p><u><strong>http://www.amazon.com/s3</strong></u></p>
<p>Next we need to setup s3sync:</p>
<p><u><strong>http://s3sync.net</strong></u></p>
<p>I want to credit <em><strong>John Eberly&#8217;s</strong></em> blog post from way back in 2006 for helping me set up s3sync. I have cheekily repeated most of his instructions in some of the steps below&#8230;</p>
<p><u><strong>http://blog.eberly.org/2006/10/09/how-automate-your-backup-to-amazon-s3-using-s3sync/</strong></u></p>
<p>s3sync requires ruby 1.8.4 or greater as well as libopenssl-ruby. I already had these setup on my server so i did not have to install them, if you don&#8217;t have these enter the command below to get them: </p>
<p><strong>sudo aptitude install ruby libopenssl-ruby</strong></p>
<p>In your /home/user/ directory download and install s3sync as follws:</p>
<p><strong>wget http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz<br />
tar xvzf s3sync.tar.gz<br />
rm s3sync.tar.gz</strong></p>
<p>You then need to create a directory for ssl certificates as well as download them. Move to the newly created s3sync folder and follow the commands below:</p>
<p><strong>cd s3sync<br />
mkdir certs<br />
cd certs<br />
wget http://mirbsd.mirsolutions.de/cvs.cgi/~checkout~/src/etc/ssl.certs.shar</strong></p>
<p>Run this command form the certs directory:</p>
<p><strong>sh ssl.certs.shar</strong></p>
<p>Now go back to the main s3sync directory. You can create an S3 &#8216;bucket&#8217; to store your database backup using s3sync eg:</p>
<p><strong>ruby s3cmd.rb createbucket mysql.mydomain.com</strong></p>
<p>Or use an GUI interface such as S3 Browser, Cockpit, or Jungle Disk:</p>
<p><u><strong>http://people.no-distance.net/ol/software/s3/<br />
http://jets3t.s3.amazonaws.com/applications/cockpit.html<br />
http://www.jungledisk.com/</strong><br />
</u></p>
<p>Next create your upload and download scripts, and edit them as follows with your own parameters. Note the &#8216;database&#8217; is just a name i gave as a sub-directory or folder within the bucket &#8211; you can call it what you want:</p>
<p><strong>sudo nano upload.sh</strong></p>
<p><em>#!/bin/bash<br />
# script to upload local directory upto s3<br />
cd /home/user/s3sync/<br />
export AWS_ACCESS_KEY_ID=yourS3accesskey<br />
export AWS_SECRET_ACCESS_KEY=yourS3secretkey<br />
export SSL_CERT_DIR=/home/user/s3sync/certs<br />
ruby s3sync.rb -r &#8211;ssl &#8211;delete /home/user/mysqlbackups/ mysql.mydomain.com:/<strong>database</strong><br />
# copy and modify line above for each additional folder to be synced</em></p>
<p><strong>sudo nano download.sh</strong></p>
<p><em>#!/bin/bash<br />
# script to download local directory upto s3<br />
cd /home/user/s3sync/<br />
export AWS_ACCESS_KEY_ID=yourS3accesskey<br />
export AWS_SECRET_ACCESS_KEY=yourS3secretkey<br />
export SSL_CERT_DIR=/home/user/s3sync/certs<br />
ruby s3sync.rb -r &#8211;ssl &#8211;delete mysql.mydomain.com:/<strong>database</strong>/ /home/user/mysqlrestores<br />
# copy and modify line above for each additional folder to be synced</em></p>
<p>Change the permissions on the files, and check the ownership &#8211; i had to change this to the current user (me):</p>
<p><strong>sudo chmod 700 upload.sh<br />
sudo chmod 700 download.sh</p>
<p>sudo chown user upload.sh<br />
sudo chown user download.sh</strong></p>
<p>Set up some S3 configuration:</p>
<p><strong>mkdir /etc/s3conf</strong><br />
<strong>cp s3config.yml.example /etc/s3conf/s3config.yml</strong></p>
<p>Edit s3config.yml with your S3 details and ssl cert path:</p>
<p><strong>sudo nano /etc/s3conf/s3config.yml</strong></p>
<p>In your s3sync directory, to run the upload and download scripts manually enter:</p>
<p><strong>./upload.sh <br />
./download.sh</strong></p>
<p>To check the upload use ruby scmd.rb as shown below, or use your preferred GUI software:</p>
<p><strong>ruby s3cmd.rb list mysql.mydomain.com</strong></p>
<p>To check the download just go to your mysqlrestores directory. I found that when i tried the download, i needed to also create a sub-directory called &#8216;database&#8217; (/home/user/mysqlrestores/database/). </p>
<p>What we now have is the ability to create mysql database backup files, as well as being able to upload and download these backup files to and from S3. But everything is being done manually! I&#8217;ll finish up by showing how this can become an automated process&#8230;</p>
<p>To get the automysqlbackup script to function automatically there are a couple of options. On Ubuntu and most other Linux distributions you should have the following &#8216;cron&#8217; directories:</p>
<p><strong>/etc/cron.daily/<br />
/etc/cron.weekly/<br />
/etc/cron.monthly/<br />
</strong></p>
<p>You can move the script to any one of these directories, and the script will run automatically every day, week, or month! On Ubuntu the .sh extension does not need to be there.</p>
<p><strong>sudo mv automysqlbackup.sh /etc/cron.daily/automysqlbackup</strong></p>
<p>But i prefer not to do this! This is because there are other default scripts or processes that run on a daily basis, and these will be run at the same time as your database backups. The default on my setup is 0625 am! I prefer to have my database dumps run at a different time, when there are no other scripts or processes running, and when my website is likely to have less traffic. The same goes for uploads to S3. The easiest way to do this is to create your own &#8216;crontab&#8217;, here you can specify what time to run your scripts. </p>
<p>Before i do this, i like to move the automyslbackup script to the s3sync directory, where it&#8217;s friends &#8216;upload&#8217; and &#8216;download&#8217; live <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
<p><strong>sudo mv automysqlbackup.sh /home/user/s3sync/automysqlbackup.sh</strong></p>
<p>Then from any directory open your own &#8216;crontab&#8217;:</p>
<p><strong>crontab -e</strong></p>
<p>Then paste in this code:</p>
<p><strong># m h  dom mon dow   command<br />
0 1 * * * /home/user/s3sync/automysqlbackup.sh<br />
30 1 * * * /home/user/s3sync/upload.sh</strong></p>
<p>Save and exit. This will basically set things up so that the automysqlbackup script will run every day at 0100 am, and so that the s3sync uploads the backups to S3 at 0130 am every day! You might need to do a Google search on crontab to find out how to customize this to suit your own needs.</p>
<p>Done!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=11&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/19/automatic-mysql-database-backups-to-amazon-s3-with-s3sync/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL Data Backups</title>
		<link>http://therailscoder.wordpress.com/2008/04/13/mysql-data-backups/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/13/mysql-data-backups/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:59:14 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/13/mysql-data-backups/</guid>
		<description><![CDATA[I have not figured out an easy or efficient way to do this yet, but this is what i am doing now. Step 1. On my Ubuntu Gutsy server, i create a mysqlbackups directory and then do a mysqldump into this directory: mysqldump -u root -p databasename &#62; databasebackup.sql Step 2. On my Macbook Pro, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=12&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have not figured out an easy or efficient way to do this yet, but this is what i am doing now. </p>
<p><u><strong>Step 1.</strong></u></p>
<p>On my Ubuntu Gutsy server, i create a <strong>mysqlbackups</strong> directory and then do a mysqldump into this directory:</p>
<p><strong>mysqldump -u root -p databasename &gt; databasebackup.sql</strong></p>
<p><u><strong>Step 2.</strong></u></p>
<p>On my Macbook Pro, i create a <strong>mysqlbackups</strong> directory and the copy the databasebackup.sql file from the server to my local machine:</p>
<p><strong>scp user@11.222.333.44:/home/user/mysqlbackups/databasebackup.sql /Users/user/mysqlbackups</strong></p>
<p><u><strong>Step 3.</strong></u></p>
<p>Upload the databasebackup.sql file to an Amazon S3 bucket using S3 Browser (see my previous post for more info on this).</p>
<p><strong>AND/OR</strong></p>
<p>Backup to CD/DVD/USB/External Hard Disk.</p>
<p><em>This is obviously a manual process that could become quite tedious. If anyone has any suggestions as to how to backup MySQL databases to Amazon S3 that is more automated, please let me know how you would do this!<br />
</em></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=12&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/13/mysql-data-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Amazon S3 with Attachment_Fu on Rails</title>
		<link>http://therailscoder.wordpress.com/2008/04/12/using-amazon-s3-with-attachment_fu-on-rails/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/12/using-amazon-s3-with-attachment_fu-on-rails/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 23:41:45 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/12/using-amazon-s3-with-attachment_fu-on-rails/</guid>
		<description><![CDATA[If you&#8217;re using the attachment_fu Rails plugin to upload files (eg images, video, etc&#8230;), you will probably be aware that there is a built-in storage option to use Amazon&#8217;s Simple Storage Service (S3). The reason i opted to use S3 was that it would take some load of my own server, and i think in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=13&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using the attachment_fu Rails plugin to upload files (eg images, video, etc&#8230;), you will probably be aware that there is a built-in storage option to use Amazon&#8217;s Simple Storage Service (S3). The reason i opted to use S3 was that it would take some load of my own server, and i think in the long run it is more efficient than using the file system or db options. Many web startups are doing exactly the same thing.</p>
<p>So how do we implement it?</p>
<p>First create an Amazon Web Services account, and sign up to use S3:</p>
<p>https://aws.amazon.com</p>
<p>Note that you will have to give some credit card details as the service is not free, but it is damn cheap!!</p>
<p>You will be given an <strong>access key id</strong> and a <strong>secret access key</strong>. These are both very long strings. </p>
<p>Next step is to create a <strong>bucket</strong>. A bucket is like a folder that will hold all your files. The easiest way to do this is get an S3 GUI, just like CocoaMSQL(Mac)/HeidiSQL(Win) for MySQL. There are a number of options to consider, eg: </p>
<p><em>S3 Browser:</em></p>
<p>http://people.no-distance.net/ol/software/s3/</p>
<p><em>Cockpit:</em></p>
<p>http://jets3t.s3.amazonaws.com/applications/cockpit.html</p>
<p><em>JungleDisk</em></p>
<p>http://www.jungledisk.com/</p>
<p>As i am using a Macbook Pro, i opted to use the S3 Browser.</p>
<p>With the <strong>S3 Browser</strong>, you just need to create a <strong>New Connection</strong> by entering you access key id and secret access key. There will be a similar option for other S3 GUI&#8217;s. Once you&#8217;ve done this you will be connected to your S3 storage and can simply add and delete buckets as you wish! I think it is a good idea to have a separate bucket for the development, test, and production versions of your app (just like you do with databases). With the S3 Browser you can also view the contents of your buckets and delete files from the buckets as well. </p>
<p>Next step is to install the S3 gem, eg:</p>
<p><strong>sudo gem install aws-s3</strong></p>
<p>Now get back to your app. I use attachment_fu for photos. So in my Photo model, i have the following:</p>
<blockquote><p><strong>has_attachment :content_type =&gt; :image,<br />
:storage =&gt; :s3,<br />
:size =&gt; 0.megabyte..3.megabytes,<br />
:resize_to =&gt; &#8217;450&#215;450&gt;&#8217;,<br />
:thumbnails =&gt; { :thumb =&gt; &#8217;150&#215;150&gt;&#8217; }</p>
<p> validates_as_attachment</strong></p></blockquote>
<p>Go to your Rails app config directory and you should see the <strong>amazon_s3.yml</strong> file.</p>
<p>Edit it as follows. Basically you need to enter your access key id and secret access key&#8217;s plus specify the bucket names:</p>
<p><strong>development:<br />
bucket_name: photos_myproject_development<br />
access_key_id: xxxxxxx<br />
secret_access_key: xxxxxxxxxxxx</p>
<p>test:<br />
bucket_name: photos_myproject_test<br />
access_key_id: xxxxxx<br />
secret_access_key: xxxxxxxxxxxx</p>
<p>production:<br />
bucket_name: photos_myproject_production<br />
access_key_id: xxxxxx<br />
secret_access_key: xxxxxxxxxxxx</strong></p>
<p>I am using Subversion for source control, but i do not check the amazon_s3.yml file into Subversion, in fact i treat it just like database.yml (there are different ways of dealing with this, i won&#8217;t be going into this right now).</p>
<p>That&#8217;s it. Pretty easy. Upload your files and then use your S3 browser to see that they are indeed on S3!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=13&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/12/using-amazon-s3-with-attachment_fu-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Apps for Email</title>
		<link>http://therailscoder.wordpress.com/2008/04/11/google-apps-for-email/</link>
		<comments>http://therailscoder.wordpress.com/2008/04/11/google-apps-for-email/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 19:10:27 +0000</pubDate>
		<dc:creator>Praveen Jayarajan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://therailscoder.wordpress.com/2008/04/11/google-apps-for-email/</guid>
		<description><![CDATA[I have been looking into how to setup and manage an email server on my VPS and came to the decision to outsource this to Google instead! It&#8217;s dead simple to setup and saves me the hassle of trying to do something that i don&#8217;t fully understand in the first place. Plus you get to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=14&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been looking into how to setup and manage an email server on my VPS and came to the decision to outsource this to Google instead! It&#8217;s dead simple to setup and saves me the hassle of trying to do something that i don&#8217;t fully understand in the first place. Plus you get to use GMail <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .You can sign up for free or go for the Premier version and pay $50/year. </p>
<p>http://www.google.com/a/</p></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/therailscoder.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/therailscoder.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/therailscoder.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/therailscoder.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/therailscoder.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=therailscoder.wordpress.com&amp;blog=6910889&amp;post=14&amp;subd=therailscoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://therailscoder.wordpress.com/2008/04/11/google-apps-for-email/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b0e2ad8b90cb3b50712c6aaca6512cc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">therailscoder</media:title>
		</media:content>
	</item>
	</channel>
</rss>
