<?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>tech kismet &#187; Alvin Kreitman</title>
	<atom:link href="http://www.techkismet.com/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://www.techkismet.com</link>
	<description>the ramblings and nonsense of Alvin Kreitman...</description>
	<lastBuildDate>Sun, 06 May 2012 15:11:40 +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>Delete Orphaned Snapshots from your EC2 Account</title>
		<link>http://www.techkismet.com/ec2-hints/delete-orphaned-snapshots-from-your-ec2-account.html</link>
		<comments>http://www.techkismet.com/ec2-hints/delete-orphaned-snapshots-from-your-ec2-account.html#comments</comments>
		<pubDate>Sat, 05 May 2012 03:50:54 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[ec2-hints]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=103</guid>
		<description><![CDATA[Have you ever noticed how sometimes snapshots just kind of pile-up for volumes you no longer need to keep snapshots for? This script is perfect for that. It requires the PEAR install of the AWS-SDK for PHP. TIP: Run it with the switch &#8211;dryrun to show you what it would have deleted. Here is the [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever noticed how sometimes snapshots just kind of pile-up for volumes you no longer need to keep snapshots for?  This script is perfect for that.  It requires the <a href="http://pear.amazonwebservices.com/">PEAR install of the AWS-SDK for PHP</a>.  </p>
<p>TIP: Run it with the switch &#8211;dryrun to show you what it would have deleted.</p>
<p>Here is the code:</p>
<p><script src="https://gist.github.com/2599434.js?file=delete_orphaned_snapshots.php"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/ec2-hints/delete-orphaned-snapshots-from-your-ec2-account.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>College Football Schedules for your iPhone.</title>
		<link>http://www.techkismet.com/widgets/college-football-schedules-iphone.html</link>
		<comments>http://www.techkismet.com/widgets/college-football-schedules-iphone.html#comments</comments>
		<pubDate>Tue, 21 Sep 2010 02:09:47 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=84</guid>
		<description><![CDATA[OK Folks &#8211; I&#8217;ve been asked over the past few years if I could do this &#8211; and I promised that one day I would. I finally spent two hours tonight and got it done! I have just completed an iphone/ipod-touch version of my somewhat famous college football schedule widget. To get started &#8211; simply [...]]]></description>
			<content:encoded><![CDATA[<p>OK Folks &#8211; I&#8217;ve been asked over the past few years if I could do this &#8211; and I promised that one day I would.  I finally spent two hours tonight and got it done!  I have just completed an iphone/ipod-touch version of my somewhat famous <a href="http://www.techkismet.com/fanwidget_ncaa_football_for_wp">college football schedule widget</a>.  </p>
<p>To get started &#8211; simply use the safari browser on your iphone and point to the address:</p>
<p>http://fanwidgets.com/iphone</p>
<p>You can select your team from the team dropdown.   If you like the schedule, you should hit the &#8220;+&#8221; at the bottom of the safari browser, and tap &#8220;Add to home screen&#8221;.  A nice little icon of your favorite team will allow quick-access to the schedule.  The schedules are updated automatically as the games are played.</p>
<p>Here&#8217;s a screenshot for the Louisville 2010 schedule:</p>
<p><a href="http://www.techkismet.com/wp-content/uploads/2010/09/IMG_0176.png"><img src="http://www.techkismet.com/wp-content/uploads/2010/09/IMG_0176-200x300.png" alt="" title="IMG_0176" width="200" height="300" class="alignnone size-medium wp-image-88" /></a></p>
<p>I hope you enjoy!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/widgets/college-football-schedules-iphone.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ec2 Snapshots &#8211; finding snapshots for volumes that no-longer exist.</title>
		<link>http://www.techkismet.com/ec2-hints/ec2-snapshots-finding-snapshots-for-volumes-that-no-longer-exist.html</link>
		<comments>http://www.techkismet.com/ec2-hints/ec2-snapshots-finding-snapshots-for-volumes-that-no-longer-exist.html#comments</comments>
		<pubDate>Thu, 16 Sep 2010 21:51:47 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[ec2-hints]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=77</guid>
		<description><![CDATA[I have at times managed dozens of EC2 instances; each with their own volume. Alongside all of these instances, I&#8217;ve had dozens of additional volumes that were attached to various instances &#8211; or used for various things. In an earlier posting &#8211; I showed you how to automatically create snapshots of your volumes. This can [...]]]></description>
			<content:encoded><![CDATA[<p>I have at times managed dozens of EC2 instances; each with their own volume.  Alongside all of these instances, I&#8217;ve had dozens of additional volumes that were attached to various instances &#8211; or used for various things.  </p>
<p><a href="http://www.techkismet.com/uncategorized/a-quick-way-to-automate-aws-ec2-snapshots.html">In an earlier posting</a> &#8211; I showed you how to automatically create snapshots of your volumes.  This can come in handy.  It can also mean you&#8217;ll end up with dozens of snapshots for volumes that no-longer exist.  The stored snapshots are taking up space and costing you money, and it can really add up if you aren&#8217;t good about cleaning that sort of thing up.  IF you automate snapshot creation &#8211; you will over time end up with snapshots that are of no value for you.  </p>
<p>KEEP IN MIND that you may <strong>purposely</strong> have snapshots for volumes that no longer exist. You may (for example) have snapshots that were backups of older volumes that you wish to keep around.  EC2 allows you to label/describe your snapshots so you can differentiate those.</p>
<p><span id="more-77"></span><br />
So I&#8217;ve designed a quick shell script that will show you all of the snapshots you have that do not match up with a current volume.  Make sure you have your environment setup and the latest version of the EC2 Tools API installed and in the PATH. You can place this command as a cron entry, or simply run it from the command line.   Here is the command:</p>
<p><code>for s in $(comm -13 <(ec2-describe-volumes |cut -f2 |sort -u) <(ec2-describe-snapshots |cut -f3| sort -u)); do ec2-describe-snapshots |grep $s; done;</code></p>
<p> Just like a few of my earlier scripts - this one-line code loop uses the AWS command line tools.  I'll explain what is happening.</p>
<p>The bulk of the activity happens in this chunk of code:</p>
<p><code>comm -13 <(ec2-describe-volumes |cut -f2 |sort -u) <(ec2-describe-snapshots |cut -f3| sort -u)</code></p>
<p>The comm command will compare the output from the first list (the list of volumes) to the second list (the list of volumes that have snapshots).   </p>
<p>The first list is the unique and sorted list of volume identifiers.<br />
The second list is the unique list of volume identifiers for all of the snapshots.</p>
<p>The comm parameters <code>-13</code> tell comm to suppress lines unique to stream 1 and lines that are common to both streams.  So what we end up with is a list of snapshotted-volumes that aren't included in the list of volumes.  Pretty clever, huh?</p>
<p>Next we iterate through this list to run the <code>ec2-describe-snapshots</code> command - grepping the output for each volume.  <strong>WARNING - this can be a time-consuming operation</strong> - especially if you have hundreds of volumes!!</p>
<p>Now the output from this command only shows you the list of snapshots.  Here is an example:</p>
<p><code>SNAPSHOT	snap-xxxxxxxx	vol-xxxxxxxx	completed	2010-05-24T20:49:17+0000	100%	XXXXXXXXXXXX 15	Lengthy Snapshot Description provided by you.<br />
SNAPSHOT	snap-xxxxxxxx	vol-xxxxxxxx	completed	2010-08-02T02:34:02+0000	100%	 XXXXXXXXXXXX 15	KEEP THIS snapshot forever<br />
SNAPSHOT	snap-xxxxxxxx	vol-xxxxxxxx	completed	2010-05-24T20:49:17+0000	100%	XXXXXXXXXXXX 15	Automated backup of a volume we don't care about anymore<br />
SNAPSHOT	snap-xxxxxxxx	vol-xxxxxxxx	completed	2010-05-24T20:49:17+0000	100%	XXXXXXXXXXXX 15	Perhaps another backup we don't care about<br />
</code></p>
<p>Now that you have this list, you can use the ec2-delete-snapshot to individually delete the un-needed snapshots.  </p>
<p>Don't you feel better for keeping your EC2 world a little cleaner.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/ec2-hints/ec2-snapshots-finding-snapshots-for-volumes-that-no-longer-exist.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FanWidgets for WordPress UPDATE</title>
		<link>http://www.techkismet.com/wp-widgets/fanwidgets-for-wordpress-update.html</link>
		<comments>http://www.techkismet.com/wp-widgets/fanwidgets-for-wordpress-update.html#comments</comments>
		<pubDate>Thu, 16 Sep 2010 18:01:57 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[wp-widgets]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=70</guid>
		<description><![CDATA[Due to popular demand, I&#8217;ve made a change in my WordPress FanWidget to allow the CSS I&#8217;m using to be overridden. The design can now be under your complete control (assuming you know a little CSS). See more information here]]></description>
			<content:encoded><![CDATA[<p>Due to popular demand, I&#8217;ve made a change in my WordPress FanWidget to allow the CSS I&#8217;m using to be overridden.  The design can now be under your complete control (assuming you know a little CSS).</p>
<p>See more information <a href="http://www.techkismet.com/fanwidget_ncaa_football_for_wp">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/wp-widgets/fanwidgets-for-wordpress-update.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick way to automate AWS EC2 Snapshots</title>
		<link>http://www.techkismet.com/uncategorized/a-quick-way-to-automate-aws-ec2-snapshots.html</link>
		<comments>http://www.techkismet.com/uncategorized/a-quick-way-to-automate-aws-ec2-snapshots.html#comments</comments>
		<pubDate>Sat, 10 Jul 2010 22:12:25 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=61</guid>
		<description><![CDATA[Earlier I posted a way to cleanup snapshots. I&#8217;ve had a few emails asking how I automated the creation. Here is a quick command line (Linux) to automate the creation of the snapshots. Make sure you have your environment setup and the latest version of the EC2 Tools API installed and in the PATH. You [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier I posted a way to cleanup snapshots.  I&#8217;ve had a few emails asking how I automated the creation.  Here is a quick command line (Linux) to automate the creation of the snapshots.  Make sure you have your environment setup and the latest version of the EC2 Tools API installed and in the PATH.  You can place this command as a cron entry, or simply run it from the command line.</p>
<pre>
for a in $(ec2-describe-volumes |grep -Ev "ATTACHMENT" |cut -f2);do ec2-create-snapshot $a; done;
</pre>
<p>All this is doing is grabbing the volume ID&#8217;s from the <code>ec2-describe-volumes</code> output &#8211; removing the extraneous information, and executing the <code>ec2-create-snapshot</code> command on each volume.    The good thing about this is that it doesn&#8217;t have to be modified as you add new volumes.  Please <a href="http://www.techkismet.com/systems-admin/automating-ec2-ebs-snapshot-cleanup.html">see my earlier posting on snapshot cleanup</a> to have a full solution from creation to cleanup.</p>
<p>Quick and easy.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/uncategorized/a-quick-way-to-automate-aws-ec2-snapshots.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Automating EC2 EBS Snapshot Cleanup</title>
		<link>http://www.techkismet.com/systems-admin/automating-ec2-ebs-snapshot-cleanup.html</link>
		<comments>http://www.techkismet.com/systems-admin/automating-ec2-ebs-snapshot-cleanup.html#comments</comments>
		<pubDate>Sun, 01 Nov 2009 06:00:57 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[systems-admin]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=40</guid>
		<description><![CDATA[I&#8217;ve recently taken on the task of building and now administering a cluster of Amazon EC2 instances. The EC2 command line tools provide all of the basic functionality you&#8217;ll need as it relates to creating new instances, EBS volumes, snapshots, and nearly everything you would ever need to do with all of the assets. The [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently taken on the task of building and now administering a cluster of Amazon EC2 instances.  The EC2 command line tools provide all of the basic functionality you&#8217;ll need as it relates to creating new instances, EBS volumes, snapshots, and nearly everything you would ever need to do with all of the assets.  The one missing piece was a script to clean-up snapshots.  The way snapshots work is they accumulate in your account&#8217;s built-in S3 area, and you pay for that.    </p>
<p>So the problem in a nutshell is I have 10 volumes, each of which is cron&#8217;ed to be snapshotted at various times of the day (depends on the specific volume as to how often it is backed up).  With 10 volumes, my S3 storage costs can get out of hand quite quickly.  So I needed to develop a set of scripts that would scan my snapshots &#8211; and remove the oldest ones &#8211; so I&#8217;m not paying for that storage.   It is important to keep a couple of snapshots for each volume (at the very least) &#8211; and in some cases, I&#8217;d like to keep several snapshots.  For example, one of my volumes is responsible for storing the main database for the CMS.  This is backed up once every two hours.  For that specific volume, I&#8217;d like to always have my choice of the last 10 snapshots to restore.  If the database all of the sudden becomes corrupt, it may be necessary to restore earlier backups to see where and when the corruption started.  Other volumes may only require the last 1 or 2 snapshots.   So this script needed to be flexible &#8211; in that I could specify how many backups I&#8217;d like to keep for each volume.</p>
<p><span id="more-40"></span><br />
<strong>PHP as an OS scripting language</strong></p>
<p>My SHELL scripting experience is pretty limited &#8211; especially when performing advanced functions.  So instead of using BASH, I chose to use PHP to develop this script.  I&#8217;ve had decent success automating functionality with PHP over the years.  It&#8217;s not nearly as clean as PERL or some OS shell scripting, but it does work, and it serves 2 other purposes: 1. consistency across the entire application, and 2. it allows me to leverage other components/libraries written for other parts of the application.   </p>
<p>A few things to know before you try to get this working:</p>
<p>1. This script assumes you have the Amazon EC2 API installed, and the appropriate environment variables properly set.  See Amazon&#8217;s documentation to get through that step.<br />
2. This script is setup to run as a cron job &#8211; so you must have it set as eXecutable.<br />
3. I make no gurantees this will work for you &#8211; but it works for perfectly for me.</p>
<p>Here&#8217;s the code:</p>
<pre>
        #!/usr/bin/php
        # Set the line above to the location of your PHP command. - don't forget your start PHP tag

        # How many snapshots to keep by volume
        $keep_qty = 2;

        # Customize how many to keep by volume.  You must specify the volume ID and the # to keep.  If you exclude a volume - it uses the default $keep_qty.
        $keep_by_volume = array("vol-identifier-1" => 2, "vol-identifier-2" => 10, "vol-identifier-3" => 6, "vol-identifier-4" => 10);

        # This script has a depdency on the EC2 tools and environment variables
        # $out stores the result of the command-line script "ec2-describe-snapshots"
        $out = array();
        exec('ec2-describe-snapshots', $out);

        /*
        The command line output looks like this:
        SNAPSHOT	snap-0Xa4X6Xe	vol-ident-1	completed	2009-10-29T05:00:34+0000	100%
        SNAPSHOT	snap-7X3XdXX8	vol-ident-1	completed	2009-10-30T05:00:34+0000	100%
        SNAPSHOT	snap-X6aX2XX5	vol-ident-2	completed	2009-10-29T05:00:21+0000	100%
        SNAPSHOT	snap-XeXXcX76	vol-ident-2	completed	2009-10-29T10:00:08+0000	100%
        SNAPSHOT	snap-X8XdXfX1	vol-ident-2	completed	2009-10-29T16:00:18+0000	100%
       */

        # Store each snapshot in it's own array element
        $snaps = array();
        foreach ($out as $snap) {
                # Notice the output above is separated by tabs.
                $snaps[] = split("\t",$snap);
        }

        # convert to a unix timestamp
        $inx = 0;   # counter
        foreach ($snaps as $s) {
                $snaps[$inx][4] = strtotime($s[4]);
                $inx++;
        }

        # You can't really sort a PHP array on an element within the array without doing some tricks
        # So here, we're going to turn the array inside out so we can sort on the volume
        # and the timestamp
        foreach ($snaps as $key => $row) {
                $column1[$key] = $row[0];
                $column2[$key] = $row[1];
                $column3[$key] = $row[2];
                $column4[$key] = $row[3];
                $column5[$key] = $row[4];
                $column6[$key] = $row[5];
        }

        # sort it
        array_multisort($column3, SORT_ASC, $column5, SORT_DESC, $snaps);

        # Now store a consolidated array of each volume with it's snapshots
        # This will look like
        $all_snaps = array();
        foreach ($snaps as $s) {
                if (empty($all_snaps[$s[2]])) {
                        $all_snaps[$s[2]] = $s[1];
                } else {
                        $all_snaps[$s[2]] .= "," . $s[1];
                }
        }

        /*
         # At this point, we should have an array that contains looks like this
         $all_snaps['volume-id-1'] = 'snapshot-id-1,snapshot-id-2'
         $all_snaps['volume-id-2'] = 'snapshot-id-1,snapshot-id-2'
        */

        # Since these are sorted from newest to oldest, we can go through these rows
        # and delete all of the entries past the $keep_qty count
        foreach ($all_snaps as $volume => $vol_snaps) {
                $snap_arr = split(",",$vol_snaps);

                $count = 1;
                # is this volume in the special keep_by_volume array we declared up top?
                if (array_key_exists($volume, $keep_by_volume)) {
                        $keep = $keep_by_volume[$volume];
                } else {
                        $keep = $keep_qty;
                }

                # Show how many snapshots we're keeping for this particular volume
                print "Volume $volume; keeping $keep\n";

                # Iterate through snapshots for this volume
                foreach ($snap_arr as $s) {
                        if ($count <= $keep) {
                                print "Keeping: $volume/ $s \n";
                        } else {
                                # Delete the snapshot, and print the output from the ec2-delete-snapshot command
                                print "Deleting: $volume/ $s\n";
                                $out = array();
                                $cmd = "ec2-delete-snapshot $s";
                                exec($cmd, $out);
                                print "Output from command $cmd: \n";
                                foreach ($out as $o) {
                                        print $o . "\n";
                                }
                        }
                        $count++;
                }
        }

       # Close your PHP here
</pre>
<p>So there you have it.  I'd love to see someone post a BASH version of a script that would do this exact same thing.  </p>
<p>I hope you found this useful.  </p>
<p><strong>UPDATE:</strong> I was made aware of a solution that does what I've built here.  <a href="http://orensol.com/">Oren Solomianik</a> offered up his solution as an alternative.   See <a href="http://code.google.com/p/ec2-delete-old-snapshots/">http://code.google.com/p/ec2-delete-old-snapshots/</a>.   It looks pretty good!  The only real difference is his script works with how many days old the snapshot is - where mine just guarantees that a certain number of backups (configurable by volume ID) are always available.  </p>
<p>Also, Oren's tool uses the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1669">Amazon EC2 PHP Library</a> - which I purposely chose not to use.  It's not that I have anything against it - I was simply trying to avoid extra requirements.</p>
<p><strong>Another Update:</strong> <a href="http://twitter.com/dohpaz42">dohpaz42</a> informs me that the split command is being deprecated in PHP 5.3 and should'nt be depended on.  You should use <a href="http://us3.php.net/manual/en/function.explode.php">explode</a> instead.  Thanks Ken!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/systems-admin/automating-ec2-ebs-snapshot-cleanup.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Twitter Lists &#8211; A nice addition &#8211; But how do you filter out the junk?</title>
		<link>http://www.techkismet.com/web-apps/twitter-lists-a-nice-addition-but-how-do-you-filter-out-the-junk.html</link>
		<comments>http://www.techkismet.com/web-apps/twitter-lists-a-nice-addition-but-how-do-you-filter-out-the-junk.html#comments</comments>
		<pubDate>Fri, 30 Oct 2009 23:15:15 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[web-apps]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/?p=37</guid>
		<description><![CDATA[I have to admit that I&#8217;m not usually one to be excited about the so-called innovation that comes out of many of these larger internet companies. In fact &#8211; very few of the so-called &#8220;enhancements&#8221; really impress me. But I&#8217;ll give props to Twitter. The road-map they&#8217;ve put together is exciting to me as a [...]]]></description>
			<content:encoded><![CDATA[<p>I have to admit that I&#8217;m not usually one to be excited about the so-called innovation that comes out of many of these larger internet companies.  In fact &#8211; very few of the so-called &#8220;enhancements&#8221; really impress me.   But I&#8217;ll give props to Twitter.  The road-map they&#8217;ve put together is exciting to me as a user first, and as an application developer as well.  </p>
<p>Perhaps the most exciting thing is integration of the lists experience into their API.   As a developer, I can see where this will allow a more realistic way of integrating relevant Twitter&#8217;ers into content site.  I can see where domain experts will build <a href="http://www.techcrunch.com/2009/10/29/not-sure-which-twitter-lists-to-follow-listorious-has-a-directory-of-the-best-ones/">lists of experts</a> in their field who, if they have something meaningful to say,  could provide for some very useful and relevant integration into content sites.   Like Robert Scoble&#8217;s list for <a href="http://listorious.com/Scobleizer/most-influential-in-tech">Most Influential in Tech</a>.</p>
<p><span id="more-37"></span><br />
<strong>The missing piece of the puzzle</strong><br />
I wonder if Twitter has plans to give Twitterers the ability to categorize their tweets to allow developers to filter out the nonsense.  If a domain expert is tweeting that he&#8217;s standing in line at the bank (or something comparably lame) &#8211; we as developers would rather skip the noise and get to the more relevant tweets.   The noise is possibly OK for some applications (like celebrity stalking or fan-sites) &#8211; but for someone looking for meaningful micro-postings from experts in a particular field &#8211; it&#8217;s going to be increasingly more important to be able to differentiate the junk from the substance.  I&#8217;m not sure exactly how they would do this, but if the stream of consciousness is ever to be considered relevant &#8211; I personally think this has to be an important part of their plans.</p>
<p>One possibility exists today &#8211; without getting Twitter to make any changes.  It would be to have the Twitter&#8217;er use something comparable to hash-tags.  For example, if a domain expert wants to tweet that their kid has a runny nose, then maybe they tag-it to be ignored by using an asterisk or an underscore.  Like:</p>
<p>&#8220;_ Little Billy has a snotty nose today&#8221;</p>
<p>If there is an accepted standard for differentiating the noise from the normally brilliant bursts of genius &#8211; we developers could easily ignore these where it&#8217;s applicable to do so.  </p>
<p><strong>It&#8217;s important</strong></p>
<p>Obviously, the reason Twitter has become so important is the fact that so many folks are engaged very actively in it.  Many very influential folks use it as a very big component of their day-to-day communications about the world they live and work.   I&#8217;m a big believer in capturing the important nuggets that come out of this.  I think at the heart of it will be very useful and engaging content.  As a developer, I want to bring that layer out and present it to users!</p>
<p>As a Twitterer myself, I like being able to use this platform to communicate about my world.  But if anyone were to ever consider me someone they&#8217;d like to listen to about Technology &#8211; I want to make it easier for them to do so. </p>
<p>Anyways &#8211; that&#8217;s enough rambling for now.  Let me know what your thoughts are.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/web-apps/twitter-lists-a-nice-addition-but-how-do-you-filter-out-the-junk.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Smart LAMP Application Backups using Amazon&#8217;s S3</title>
		<link>http://www.techkismet.com/tech-ramblings/smart_lamp_backups_using_s3.html</link>
		<comments>http://www.techkismet.com/tech-ramblings/smart_lamp_backups_using_s3.html#comments</comments>
		<pubDate>Fri, 02 Nov 2007 03:02:19 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[tech-ramblings]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/tech-ramblings/smart_lamp_backups_using_s3.html</guid>
		<description><![CDATA[Repeat after me: I must backup my LAMP applications!! If you&#8217;re like me &#8211; you&#8217;ve hacked your way through several iterations of backup scripts over the years. I can&#8217;t even imagine how screwed I&#8217;d be if my server went down without a backup. I have thousands of hours worth of code and ultra important and [...]]]></description>
			<content:encoded><![CDATA[<p>Repeat after me: I must backup my LAMP applications!!  If you&#8217;re like me &#8211; you&#8217;ve hacked your way through several iterations of backup scripts over the years.  I can&#8217;t even imagine how screwed I&#8217;d be if my server went down without a backup.  I have thousands of hours worth of code and ultra important and sensitive data.</p>
<p>In the past, I put together scripts that had hard-coded commands to tar/ftp the applications and data to a remote server.  As I added new applications &#8211; or as applications would mature (and spread into other areas of the server), I would simply modify the original scripts to include the new stuff. So, of course (because I&#8217;m lazy sometimes), I had on several occasions inadvertently neglected to include something in my backup scripts.  Over time, my backup scripts became ugly, unmanageable, and over-complicated.</p>
<p>So I came up with a new strategy.  Why not develop a set of scripts that:<br />
<span id="more-13"></span></p>
<p>a. will back up the server nightly directly to remote storage<br />
b. do not have to be constantly modified as new applications or application components are added.  </p>
<p>Those seem like reasonable goals.  </p>
<p>First, a little background; I have a dedicated Linux server running CentOS (although this technique should be Linux version agnostic).  I host roughly 20 different domains on this server (not all of them are mine).  For the stuff I develop, these LAMP applications typically consist of: </p>
<p>1. an htdocs directory (where the web-application is served from).<br />
2. one or more MySQL databases (for application data and framework specific databases and tables)<br />
3. associated scripts (for cron jobs, external activities, etc)</p>
<p>So to do this, you have to possibly reorganize your application.  Just be careful when you are following these instructions not to break your application, and make sure you think of config files, crontabs, etc.  </p>
<p>Let&#8217;s get started:</p>
<p>1.  <strong>Re-organize your applications, and use consistent naming conventions</strong>: Choose a path on your server, and store your application folder and scripts folders there.  I use <code>/usr/local</code>.  My application folders always follow the pattern <code>htdocs.domain</code> where domain is obviously the name of the domain (i.e. techkismet.com).  So for this website, the full-path/name of the application is <code>/usr/local/htdocs.techkismet</code>.  Remember, if you move your application &#8211; you will need to make changes to your apache configuration files to point to your new htdocs directory.</p>
<p>I do the same thing with my application scripts.  Using the same example before, my scripts folder would be <code>/usr/local/scripts.techkismet</code></p>
<p>2. <strong>Create a home for your backup scripts and associated files</strong>: I used <code>/usr/local/backups. </code>. You should also create a sub-folder within that folder called &#8220;temp&#8221;.  This is where your script will temporarily put all of the files that are being backed-up.</p>
<p>3. <strong>Build your backup shell script</strong></p>
<p>The main backup script is a BASH shell-script that identifies and backs-up each of your applications and databases.  This file is called <code>/usr/local/backups/backup.sh</code>.  Here is my version as a starting point:</p>
<pre class="code">
<code>

#!/bin/sh

# First remove the contents of the temp directory - the files in there are from yesterday.
rm -rf /usr/local/backups/temp/*

# auto-dump all mysql databases
for a in $(echo "show databases" | mysql -u user --password=password | egrep -v '^Database|^information_schema|^test'); do mysqldump -u user --pasword=password $a &gt; /usr/local/backups/temp/$a.sql; done;

# Auto backup all htdocs.* and scripts.* folders in /usr/local (these are all of the application and scripts directories);
cd /usr/local
for a in $(ls -d htdocs.*); do tar -czf /usr/local/backups/temp/$a-backup.tgz $a/* &gt;/dev/null 2&gt;&amp;1; done;
for a in $(ls -d scripts.*); do tar -czf /usr/local/backups/temp/$a-backup.tgz $a/* &gt;/dev/null 2&gt;&amp;1; done;

# Additional directories/files to handle - put any other files you wish to back up here.
tar -czf /usr/local/backups/temp/other-files.tgz /path/to/local/files/* /path/to/another/file &gt;/dev/null 2&gt;&amp;1

# Backup this script and others in this directory
tar -czf /usr/local/backups/temp/backupscripts.tgz /usr/local/backups/*.sh  /usr/local/backups/s3-bash/* &gt;/dev/null 2&gt;&amp;1
</code>
</pre>
<p>Let&#8217;s take a closer look at what we&#8217;re doing here:</p>
<p><strong>MySql database backup:</strong></p>
<pre class="code">
<code>
for a in $(echo "show databases" | mysql -u user --password=password | egrep -v '^Database|^information_schema|^test'); do mysqldump -u user --pasword=password $a &gt; /usr/local/backups/temp/$a.sql;
</code></pre>
<p>This nifty command will iterate through your mysql databases, and do a mysqldump of these databases into a file of the  same-name (with a .sql extension) in the temp folder.  You should obviously change the user and password to a mysql user that has the appropriate rights from localhost.  </p>
<p>The &#8220;egrep -v&#8221; command will exclude from the list the items identified in the string.  The first item in the list (&#8220;Database&#8221;) is required.  This text is included in the output of &#8220;show databases&#8221; and it&#8217;s not a real database obviously.  You can include whichever database you prefer not to backup in this list.  I&#8217;m excluding the databases &#8220;information_schema&#8221; and &#8220;test&#8221; from the backups.</p>
<p>So this multi-piped command produces a list of databases as strings, and each of these strings will be passed to the mysqldump command. The corresponding backup files will be created and stored in the temp folder.</p>
<p><strong>Application and Scripts Folder backup:</strong></p>
<p>The next few commands will go through a comparable process for the htdocs and scripts folders.  The commands:</p>
<pre class="code">
<code>
cd /usr/local
for a in $(ls -d htdocs.*); do tar -czf /usr/local/backups/temp/$a-backup.tgz $a/* &gt;/dev/null 2&gt;&amp;1; done;
for a in $(ls -d scripts.*); do tar -czf /usr/local/backups/temp/$a-backup.tgz $a/* &gt;/dev/null 2&gt;&amp;1; done;
</code></pre>
<p>These are a little less complicated, but they achieve the same objective.  The <code>ls -d</code> command  lists all directories that match the pattern htdocs.* (and scripts.*).  The results of the &#8220;ls&#8221; operation are streamed one at a time to the tar command.  When this is finished, all of these directories will have been &#8220;tar&#8217;d&#8221; (using a filename that matches the directory) and stored in the temp directory.</p>
<p><strong>Other Items to backup</strong></p>
<p>There will always be additional files (not included in the strucutres identified above) that you will want to backup.  Apache configuration files, php.ini, digital certificates,  server documentation/notes, other application configuration files, etc.  You can back these up either in groups, or individually using something like the following command:</p>
<pre class="code">
<code>
# Additional directories/files to handle
tar -czf /usr/local/backups/temp/other-files.tgz /path/to/local/files/* /path/to/another/file &gt;/dev/null 2&gt;&amp;1
</code></pre>
<p>Add any other files as you see fit.  </p>
<p>And, for good measure, you may wish to backup the &#8220;backup&#8221; directory and scripts.</p>
<pre class="code">
<code>
# Backup this script and others in this directory
tar -czf /usr/local/backups/temp/backupscripts.tgz /usr/local/backups/*.sh  /usr/local/backups/s3-bash/* &gt;/dev/null 2&gt;&amp;1</code></pre>
<p>4. <strong>CRON it</strong><br />
You should cron this backup script to run at an appropriate time.  I chose 4:00 AM, as that is when my domain activity is at it&#8217;s lowest.  </p>
<p><strong>Next step: Sending the files to Amazon&#8217;s S3</strong><br />
So we&#8217;ve only really done 1/2 the work so far, right?  You need to send these locally backed up files to a remote storage area.  This is where Amazon&#8217;s S3 comes in to play.  You probably noticed that I&#8217;ve decoupled the backup script above from the transmission script (that we&#8217;re about to talk about).  This was my goal.  If I need to re-transmit for any reason, I can do that without regenerating all of the files.</p>
<p>I recently started using S3, and I&#8217;m very cooled out by it.  It&#8217;s a web-services accessible data-storage service, and it can be used to publicly or privately store anything you want.  You can find out more by visiting http://aws.amazon.com/s3.  Pricing is reasonable.  They charge for bandwidth and storage.  My typical bill runs around $2.40 a month &#8211; and my typical nightly backup is right around 600 MB.  </p>
<p>As I mentioned earlier, I send full-backups each night.  There are more-advanced tools that allow you to &#8220;sync&#8221; between local data-stores and S3.  This should cut down on your bandwidth usage &#8211; and could create a substantial savings. I may make a future posting about this technique. </p>
<p>So, on to the details.   Once I signed up for AWS S3, I was able to retrieve my access identifier and my &#8220;secret&#8221; access key.  For my scripts, I used a utility called <a href="http://code.google.com/p/s3-bash/" title="S3 Bash" target="_blank">S3-Bash</a> by Raphael James Cohn.  This set of BASH scripts allow you to access your S3 buckets from the Linux command line (get, put, and delete).</p>
<p>So do this:</p>
<p>1. Sign up for AWS S3 (if you haven&#8217;t already).  Get your access identifier and secret keys.  Copy and paste them someplace where you can have them readily available.<br />
2. Download the <a href="http://code.google.com/p/s3-bash/">S3-Bash code</a>.<br />
3. Create a folder in your backups folder called s3-bash, and place the S3-bash scripts in there.<br />
4. Create a text file for each of your access key and secret key.  I used the file names &#8220;key.txt&#8221; and &#8220;secret_40.txt&#8221; respectively.  These files will be used with the s3-bash commands to associate the transmission with your AWS account.  <strong>Please NOTE:</strong> Make sure to follow the instructions <a href="http://code.google.com/p/s3-bash/issues/detail?id=1&amp;can=1" target="_blank">here</a> if you are using an editor such as &#8220;vim&#8221;, it will store a line-feed automatically at the end of the line.   The files need to be 20 and 40 bytes respectively and the commands won&#8217;t work if the files sizes are not exact.  Also, please note that your server time should be accurate for s3-bash commands to work.  You can read about this requirement on the AWS knowledge-base.</p>
<p>5.  You will need to create your destination &#8220;bucket&#8221; (or folder) on S3.  There are command-line scripts that can do this, but I found it easiest to download and install a browser plugin for FireFox called s3Fox.  You can download/install it at <a href="https://addons.mozilla.org/en-US/firefox/addon/3247">https://addons.mozilla.org/en-US/firefox/addon/3247</a>.  If you don&#8217;t use FireFox &#8211; you might want to look into the other options on the AWS knowledge base.</p>
<p>Otherwise, once you&#8217;ve installed the plugin (and set it up to access your account) you should create the bucket to store your backup-files.  Mine is called &#8220;daily-backup&#8221;</p>
<p>6. Create a script called <code>/usr/local/backups/daily2s3.sh</code>.  Here is what mine looks like including comments:</p>
<pre class="code"><code>
# This script is executed nightly after backup.sh which produces the files.
# The key files below are required for access to S3
# The key files have to be 20 (for key.txt)  and 40 bytes (for secret_40.txt) .  Use dd to remove the lf if the file was created using VI
# for example
#
# dd if=&lt;21bytefile.txt&gt; of=&lt;20bytefile&gt; bs=1 count=20

cd /usr/local/backups/temp
for a in $(ls); do /usr/local/backups/s3-bash/s3-put -k `cat /usr/local/backups/s3-bash/key.txt` -s /usr/local/backups/s3-bash/secret_40.txt -T $a -c application/octet-stream /daily-backup/$a; done;
</code></pre>
<p>As you can see, this script iterates through the files created in the temp folder &#8211; and &#8220;put&#8221;s them in the &#8220;daily-backup&#8221; bucket on S3.  The &#8220;cat&#8221; commands executed inline incorporate the keys when needed, and keep the keys private (in case someone happens to do a &#8220;ps ax&#8221; when the command is running.  You should cron this script as well.  Make sure you schedule it after the backup script &#8211; and give your backup script plenty of time to finish.  In my case, I scheduled these two scripts 30 minutes apart.</p>
<p><strong>That&#8217;s it</strong></p>
<p>I hope you find this useful.  Please feel free to leave me comments/feedback!</p>
<p>            <script type="text/javascript">
            digg_bgcolor = '#fff';
            digg_url = 'http://www.techkismet.com/tech-ramblings/smart_lamp_backups_using_s3.html';
            digg_skin = 'compact';
            digg_window = 'new';
            </script><br />
            <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/tech-ramblings/smart_lamp_backups_using_s3.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I apparently look a little like Kate Blanchett!</title>
		<link>http://www.techkismet.com/uncategorized/i-dont-think-so.html</link>
		<comments>http://www.techkismet.com/uncategorized/i-dont-think-so.html#comments</comments>
		<pubDate>Tue, 18 Sep 2007 15:18:17 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/uncategorized/i-dont-think-so.html</guid>
		<description><![CDATA[Go figure.  I found this cool image analysis tool that attempts to see what celebrities you might resemble&#8230;]]></description>
			<content:encoded><![CDATA[<p>Go figure.  I found this cool image analysis tool that attempts to see what celebrities you might resemble&#8230;</p>
<p><span id="more-12"></span></p>
<p><a href="http://www.myheritage.com" title="MyHeritage - share black and white photos with facial recognition technology" alt="MyHeritage - share black and white photos with facial recognition technology" target="_blank"><img src="http://www.myheritagefiles.com/H/storage/site1/files/14/85/82/148582_109896b5befe6434hqzk53.JPG" border="0" height="297" width="499" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/uncategorized/i-dont-think-so.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t you love College Football?</title>
		<link>http://www.techkismet.com/tech-ramblings/college-football-schedule-widget.html</link>
		<comments>http://www.techkismet.com/tech-ramblings/college-football-schedule-widget.html#comments</comments>
		<pubDate>Mon, 10 Sep 2007 00:02:43 +0000</pubDate>
		<dc:creator>Alvin Kreitman</dc:creator>
				<category><![CDATA[tech-ramblings]]></category>

		<guid isPermaLink="false">http://www.techkismet.com/tech-ramblings/dont-you-love-college-football.html</guid>
		<description><![CDATA[OK, so I&#8217;m making my first real contribution to the WordPress community. I&#8217;m a freak for college football; I have been for as long as I can remember. A few years ago, I developed a widget in Yahoo Widgets (formally Konfabulator). It&#8217;s called liveSchedule, and it allows users to display their favorite team&#8217;s schedule including [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so I&#8217;m making my first real contribution to the WordPress community.  I&#8217;m a freak for college football; I have been for as long as I can remember.  A few years ago, I developed a widget in <a href="http://widgets.yahoo.com" target="_blank">Yahoo Widgets</a> (formally Konfabulator).  It&#8217;s called <a href="http://www.techkismet.com/liveschedule-yahoo-widget" target="_blank">liveSchedule</a>, and it allows users to display their favorite team&#8217;s schedule including results, record, and current ranking.</p>
<p>So I had this great idea that I should make a WordPress Widget that does the same thing.  I&#8217;m releasing it to the world today!  You can see a live example on the bottom left of this page.  For more information, I&#8217;ve setup this <a href="http://www.techkismet.com/fanwidget_ncaa_football_for_wp" target="_blank">special page</a> where you can get additional information and download it for yourself!</p>
<p>I&#8217;d love to get your feedback and suggestions for the next version!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techkismet.com/tech-ramblings/college-football-schedule-widget.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

