<?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:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Isotropic &#187; programming</title>
	<atom:link href="http://www.hornlo.org/isotropic/topics/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hornlo.org/isotropic</link>
	<description>Where ever you go, there you are.</description>
	<lastBuildDate>Wed, 25 Jan 2012 21:14:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>DLL Hell 2.0</title>
		<link>http://www.hornlo.org/isotropic/2009/10/05/dll-hell-2-0/</link>
		<comments>http://www.hornlo.org/isotropic/2009/10/05/dll-hell-2-0/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 17:55:26 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[dll hell]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SxS]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=741</guid>
		<description><![CDATA[One of my more popular posts, &#8220;Elimination of &#8216;DLL Hell&#8217;, correction of fatal flaws, and reinventing the Internet&#8220;, may need updating&#8230;. See &#8220;&#8216;Side By Side Assemblies&#8217; Bring DLL Hell 2.0&#8221; at Slashdot. Related Posts (in theory, but probably not):Elimination of &#8216;DLL Hell&#8217;, correction of fatal flaws, and reinventing the InternetCar WarrantyIrrefutable LogicMeme: First sentence of [...]]]></description>
			<content:encoded><![CDATA[<p>One of my more popular posts, &#8220;<a href="http://www.hornlo.org/isotropic/2000/11/23/elimination-of-dll-hell-correction-of-fatal-flaws-and-reinventing-the-internet/">Elimination of &#8216;DLL Hell&#8217;, correction of fatal flaws, and reinventing the Internet</a>&#8220;, may need updating&#8230;.</p>
<p>See &#8220;<a href="http://developers.slashdot.org/story/09/10/04/1956225/Side-By-Side-Assemblies-Bring-DLL-Hell-20">&#8216;Side By Side Assemblies&#8217; Bring DLL Hell 2.0</a>&#8221; at Slashdot.</p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2000/11/23/elimination-of-dll-hell-correction-of-fatal-flaws-and-reinventing-the-internet/" rel="bookmark" class="crp_title">Elimination of &#8216;DLL Hell&#8217;, correction of fatal flaws, and reinventing the Internet</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/12/car-warranty/" rel="bookmark" class="crp_title">Car Warranty</a></li><li><a href="http://www.hornlo.org/isotropic/2008/10/01/irrefutable-logic/" rel="bookmark" class="crp_title">Irrefutable Logic</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/07/meme-first-sentence-of-first-post-of-each-month-of-2008/" rel="bookmark" class="crp_title">Meme: First sentence of first post of each month of 2008</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/08/key-personnel-evacuation-plan/" rel="bookmark" class="crp_title">Key Personnel Evacuation Plan</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/05/12/car-warranty/" rel="bookmark" class="wherego_title">Car Warranty</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/08/key-personnel-evacuation-plan/" rel="bookmark" class="wherego_title">Key Personnel Evacuation Plan</a></li><li><a href="http://www.hornlo.org/isotropic/2009/10/09/quote-of-the-day/" rel="bookmark" class="wherego_title">Quote of the day</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2009/10/05/dll-hell-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Math</title>
		<link>http://www.hornlo.org/isotropic/2009/05/17/computer-math/</link>
		<comments>http://www.hornlo.org/isotropic/2009/05/17/computer-math/#comments</comments>
		<pubDate>Sun, 17 May 2009 09:44:14 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bcd]]></category>
		<category><![CDATA[floating point]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=467</guid>
		<description><![CDATA[In early April I said &#8220;The real problem was that new users either believed that computers understood and used ideal mathematics, or had come from &#8216;mainframe&#8217; backgrounds where all math was done with decimal data types rather than defaulting to low-precision floating point.&#8221; So I was tickled to see Jeff Atwood&#8217;s blog post on 5/13, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.hornlo.org/media/comp-math.png" width="68" height="108" align="left" alt="2+2=5" title="2+2=5" style="padding-right: 1em; padding-bottom: 1em;" /> In early April <a href="http://www.hornlo.org/isotropic/2009/04/04/need-to-know/" title="Need to know (under 'The Compiler Is Broken')">I said</a> &#8220;The real problem was that new users either believed that computers understood and used ideal mathematics, or had come from &#8216;mainframe&#8217; backgrounds where all math was done with decimal data types rather than defaulting to low-precision floating point.&#8221;</p>
<p>So I was tickled to see Jeff Atwood&#8217;s <a href="http://www.codinghorror.com/blog/" title="Coding Horror">blog</a> post on 5/13, &#8220;<a href="http://www.codinghorror.com/blog/archives/001266.html">Why Do Computers Suck at Math?</a>&#8221; in which he mentions several infamous glitches (mostly fixed now) in the Google and MS Windows calculators, MS Excel 2007, and the ill-fated Ariane 5 rocket.  He also gives a summary of floating point and recommends David Goldberg&#8217;s &#8220;<a href="http://docs.sun.com/source/806-3568/ncg_goldberg.html">What Every Computer Scientist Should Know About Floating-Point Arithmetic</a>&#8220;.  You may want to see Wikipedia&#8217;s &#8220;<a href="http://en.wikipedia.org/wiki/Floating_point">floating point</a>&#8221; entry for a less technical overview.</p>
<p>As usual, the many comments expand and correct his main article.  I encourage you to at least skim through them.  However, there were a couple things that I did find more amusing than edifying.</p>
<p>First, there was a comment that said floating point math was developed for the x87 coprocessors to compensate for low power and scarce memory.  Ahem.  That&#8217;s right up there with Al Gore inventing the Internet and Bill Gates inventing UNIX.  Digging through my own junk closet I found a 1975 printing of &#8220;Introduction to Programming&#8221; which includes assembly level programming of the PDP-8e&#8217;s floating point unit.  A little more digging turned up a 1970 copy of Schaum&#8217;s Outline Series &#8220;Introduction to Computer Science&#8221; which not only discusses floating point, but also has you work out fp logic circuits (yes, really: <tt>and</tt>, <tt>or</tt>, and <tt>not</tt> gates)!  Wheee, I don&#8217;t remember doing those exercises.  Oh, to close the circle from the comments, there&#8217;s <acronym title="Binary Coded Decimal">BCD</acronym> &#8212; my 1981 MC6809 Microprocessor Programming Manual shows the MC6809 had instructions for BCD.  These were mini- and micro-processors; the actual history of these concepts is much older of course.</p>
<p>More entertaining, however, is the lengthly discussion of whether &#8220;0.999&#8230; == 1&#8243;.  Really.  Now, to be right up front about it, this is <em>true</em>.  <tt>0.999...</tt> <em>is</em> <tt>1</tt>.  None of this &#8220;approaching&#8221; or &#8220;almost but not quite&#8221; stuff.  Those are two ways of representing a single ideal number: 1.  Apparently this is a big deal, kinda like the thermal properties of blankets I also mentioned in the April post.  For the short answer, see &#8220;<a href="http://mathforum.org/dr.math/faq/faq.0.9999.html">Why does 0.9999&#8230; = 1 ?</a>&#8220;; for a longer discussion, see &#8220;<a href="http://en.wikipedia.org/wiki/0.999...">0.999&#8230;</a>&#8220;.</p>
<p><div class="note"><div class="notehelp">Q. How many mathematicians does it take to screw in a light bulb?<br />&nbsp;<br />A. 0.999&#8230;</div></div></p>
<p>I guess I have the sort of twisted mind in which all of this makes perfect sense.  Everything is just layer upon layer of convention, filtering, abstraction, and indirection.</p>
<p>I just recalled a discussion of how computers &#8220;really&#8221; store numbers that came up while going over converting among decimal, binary, octal, and hex representations.  Along the lines of how can &#8220;it&#8221; tell whether it&#8217;s storing a hex or octal number, or maybe even a character, or something else.  Hmm, kinda like the &#8220;how does a thermos &#8216;know&#8217; whether to keep stuff hot or cold&#8221; &#8212; it&#8217;s the wrong question; you&#8217;re using the wrong filter.</p>
<p>I once had someone dabbling with programming ask me what arrays were good for, since they didn&#8217;t understand them at all; I wasn&#8217;t sharp enough to give them a good answer.  But for &#8220;real&#8221; programming, it seemed that the big sythe-level filter was pointers, or more generally, indirection.  It either clicked or they were lost.  Nightmare:  an array of pointers to functions returning pointers to structures containing pointers to &#8230;.</p>
<p>But I love that sorta stuff; you shouldn&#8217;t be surprised that <a href="http://en.wikipedia.org/wiki/G%C3%B6del,_Escher,_Bach">Gödel, Escher, Bach: An Eternal Golden Braid</a> is one of my favorite books.</p>
<p>As a friend of mine says &#8220;Well, that explains a lot.&#8221;</p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/04/04/need-to-know/" rel="bookmark" class="crp_title">Need to know</a></li><li><a href="http://www.hornlo.org/isotropic/2009/12/12/tv-math/" rel="bookmark" class="crp_title">TV Math</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/" rel="bookmark" class="crp_title">Don&#8217;t Look Don&#8217;t Tell</a></li><li><a href="http://www.hornlo.org/isotropic/2009/01/06/micromanagement-zombies/" rel="bookmark" class="crp_title">Micromanagement Zombies</a></li><li><a href="http://www.hornlo.org/isotropic/2009/08/19/a-visit-from-dec-corporate/" rel="bookmark" class="crp_title">A Visit From DEC Corporate</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/04/04/need-to-know/" rel="bookmark" class="wherego_title">Need to know</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2009/05/17/computer-math/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Look Don&#8217;t Tell</title>
		<link>http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/</link>
		<comments>http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/#comments</comments>
		<pubDate>Fri, 15 May 2009 23:10:05 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[Life-Society]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[evidence]]></category>
		<category><![CDATA[legal system]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[proprietary software]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=458</guid>
		<description><![CDATA[It&#8217;s time for another rantish post. [T]he manufacturer maintained that the system was perfect, and that revealing the source code would be damaging to its business. They were right about the second part, of course, because it turned out that the code was terrible. [...] Basically, the system was designed to return some sort of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.hornlo.org/media/lady-justice.png" width="98" height="172" align="left" alt="Lady Justice" title="Lady Justice" style="padding-right: 1em; padding-bottom: 1em;" /> It&#8217;s time for another rantish post.</p>
<blockquote><p>
[T]he manufacturer maintained that the system was perfect, and that revealing the source code would be damaging to its business. They were right about the second part, of course, because it turned out that the code was terrible.<br />
[...]<br />
Basically, the system was designed to return some sort of result regardless.<br />
<small>&#8211;<cite>Bruce Schneier, <a href="http://www.schneier.com/blog/archives/2009/05/software_proble.html">Software Problems with a Breath Alcohol Detector</a></cite></small>
</p></blockquote>
<p>Schneier goes on to say that &#8216;&#8221;You can&#8217;t look at our code because we don&#8217;t want you to&#8221; simply isn&#8217;t good enough.&#8217; in the realm of evidence and other legal situations.</p>
<p>Don&#8217;t forget the debacle with <a href="http://en.wikipedia.org/wiki/Electronic_voting">electronic voting</a> systems, either.</p>
<p>You would think that the primary goal of a programmer would be correctness.  After all, whenever <em>I</em> use something, whether software based or not, I expect correct functioning, and if I don&#8217;t get that, then I consider the product or procedure <em>broken</em> &#8230; but then I&#8217;m just a naive consumer.  An ideal product would first have to be &#8220;correct&#8221;, but also relatively accurate (for instance, &#8220;a few meters&#8221; is good enough for GPS), and performant (a speedometer should display your current speed, not what it was five minutes ago).</p>
<p>However, programmers don&#8217;t work in an ideal world, and are rarely in charge.  Usually the real priority is the  bottom line, and every thing else follows.  You probably have seen the meme</p>
<ol>
<li>something</li>
<li>???</li>
<li>Profit!</li>
</ol>
<p>Let me put that in priority order and expand it:</p>
<ol>
<li>Profit!</li>
<li>release</li>
<li>pretty</li>
<li>fast</li>
<li>precise</li>
<li>correct</li>
</ol>
<p>Years ago in <i>Windows Developer</i><sup> [<a href="http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/#footnote_0_458" id="identifier_0_458" class="footnote-link footnote-identifier-link" title="I kept this particular issue for a long time, due to this article, but I can&amp;#8217;t find it now; I&amp;#8217;ll update this post if I do">1</a>]</sup> someone from a major software house (heh) explicitly stated that the &#8220;user experience&#8221; was the most important thing, and that correct functioning should be sacrificed for the sake of a better UX.  WTF?  I obviously have never been in the target demographic for those products.  I think this was the same issue where they kept referring to a current software development product, still in active development, as &#8220;legacy code&#8221;, pushing instead a still-in-beta product as the only way to go, leaving those dinosaurs (who converted to the legacy system just a year or so ago) behind in the primordial dust.  But I&#8217;m not cynical.</p>
<p>In the precise category (precision, accuracy, and resolution are unrelated), I recall a 10KVA UPS system I ran across.  I thought it was pretty cool, if overkill, that it showed the current flow to a couple or three decimal places &#8230; until I realized that it only had so many discrete values that it displayed.  The &#8220;precision&#8221; was meaningless; there were only about three different &#8220;.nnn&#8221; values ever displayed.  From what I remember, the current values were probably a geometric sequence &#8212; sort of like the 10% <a href="http://en.wikipedia.org/wiki/Resistor#Preferred_values">resistor preferred value scale</a> (10 12 15 18 22 27 33 39 47 56 68 82) &#8212; with the decimals thrown in just for appearance&#8217;s sake.</p>
<p align="right"><small>image: <cite><a href="http://en.wikipedia.org/wiki/File:Lady_justice_standing.png">Lady justice standing.png</a>, Wikimedia Commons</cite></small></p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2008/12/31/its-gonna-be-a-long-day/" rel="bookmark" class="crp_title">It&#8217;s gonna be a long day</a></li><li><a href="http://www.hornlo.org/isotropic/2009/02/20/broken-windows/" rel="bookmark" class="crp_title">Broken Windows</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/02/flailing-around/" rel="bookmark" class="crp_title">Flailing Around</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/31/smile-when-you-say-that/" rel="bookmark" class="crp_title">Smile when you say that</a></li><li><a href="http://www.hornlo.org/isotropic/2009/07/05/anti-malware-software/" rel="bookmark" class="crp_title">Anti-Malware Software</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/07/05/anti-malware-software/" rel="bookmark" class="wherego_title">Anti-Malware Software</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/02/flailing-around/" rel="bookmark" class="wherego_title">Flailing Around</a></li><li><a href="http://www.hornlo.org/isotropic/2009/02/20/broken-windows/" rel="bookmark" class="wherego_title">Broken Windows</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/31/smile-when-you-say-that/" rel="bookmark" class="wherego_title">Smile when you say that</a></li></ul></div><ol class="footnotes"><li id="footnote_0_458" class="footnote">I kept this particular issue for a long time, due to this article, but I can&#8217;t find it now; I&#8217;ll update this post if I do</li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Broken Windows</title>
		<link>http://www.hornlo.org/isotropic/2009/02/20/broken-windows/</link>
		<comments>http://www.hornlo.org/isotropic/2009/02/20/broken-windows/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 21:43:57 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[Life-Society]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=366</guid>
		<description><![CDATA[This isn&#8217;t about Microsoft Windows. The Parable of the Broken Window describes a shopkeeper whose window is broken by a little boy. Everyone sympathizes with the man whose window was broken, but pretty soon they start to suggest that the broken window makes work for the glazier, who will then buy bread, benefiting the baker, [...]]]></description>
			<content:encoded><![CDATA[<p>This isn&#8217;t about Microsoft Windows.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Parable_of_the_broken_window">Parable of the Broken Window</a> describes<br />
<blockquote>a shopkeeper whose window is broken by a little boy. Everyone sympathizes with the man whose window was broken, but pretty soon they start to suggest that the broken window makes work for the glazier, who will then buy bread, benefiting the baker, who will then buy shoes, benefiting the cobbler, etc. Finally, the onlookers conclude that the little boy was not guilty of vandalism; instead he was a public benefactor, creating economic benefits for everyone in town.</p></blockquote>
<p>The Wikipedia article quotes the original parable by Frédéric Bastiat, refers to the <a href="http://en.wikipedia.org/wiki/Unintended_consequences">law of unintended consequences</a>, then goes on to discuss the parable&#8217;s fallacy, interpretations, and applications.</p>
<p>Something current economists and pundits should keep in mind, don&#8217;t ya think?</p>
<p>However, I didn&#8217;t discover the parable until after I&#8217;d already started working on this post, triggered by reading Bruce Schneier&#8217;s &#8220;<a href="http://www.schneier.com/blog/archives/2009/02/the_broken_wind.html">The &#8220;Broken Windows&#8221; Theory of Crimefighting</a>, which links to a Boston Globe article by Carolyn Y. Johnson: <a href="http://www.boston.com/news/local/massachusetts/articles/2009/02/08/breakthrough_on_broken_windows/">Breakthrough on &#8216;broken windows&#8217;</a>:<br />
<blockquote>The results, just now circulating [the study was in 2005] in law enforcement circles, are striking: A 20 percent plunge in calls to police from the parts of town that received extra attention. It is seen as strong scientific evidence that the long-debated &#8220;broken windows&#8221; theory really works &#8211; that disorderly conditions breed bad behavior, and that fixing them can help prevent crime.</p></blockquote>
<p>Long-debated since the idea was introduced in The Atlantic&#8217;s March 1982 &#8220;<a href="http://www.theatlantic.com/doc/198203/broken-windows">Broken Windows</a>&#8221; by George L. Kelling and James Q. Wilson, which led to the 1996 book <i><a href="http://en.wikipedia.org/wiki/Fixing_Broken_Windows">Fixing Broken Windows: Restoring Order and Reducing Crime in Our Communities</a></i> by George L. Kelling and Catherine Coles.</p>
<p>But, again, this post really wasn&#8217;t meant to be about crime or urban renewal.  Whenever I hear &#8220;broken windows&#8221;, I&#8217;m always reminded of one of favorite short books on programming: <i><a href="http://www.pragprog.com/titles/tpp/the-pragmatic-programmer">The Pragmatic Programmer: From Journeyman to Master</a></i>, by Andrew Hunt and David Thomas.  In <a href="http://www.pragprog.com/the-pragmatic-programmer/extracts/software-entropy" title="Software Entropy (Extract from The Pragmatic Programmer)">this extract</a> they say:</p>
<blockquote><p>
Don’t leave &#8220;broken windows’’ (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a “Not Implemented” message, or substitute dummy data instead. Take some action to prevent further damage and to show that you’re on top of the situation.</p>
<p>We’ve seen clean, functional systems deteriorate pretty quickly once windows start breaking. There are other factors that can contribute to software rot, and we’ll touch on some of them elsewhere, but neglect accelerates the rot faster than any other factor.</p>
<p>You may be thinking that no one has the time to go around cleaning up all the broken glass of a project. If you continue to think like that, then you’d better plan on getting a dumpster, or moving to another neighborhood. Don’t let entropy win.
</p></blockquote>
<p>So.  I&#8217;d intended to quickly jump from a passing reference to Schneier&#8217;s post into software development, but got sidetracked and now I&#8217;m out of time (or attention span, anyway).</p>
<p>I started out saying that this wasn&#8217;t about Microsoft Windows, but I just can&#8217;t help myself &#8230; perhaps if Microsoft had paid more attention to broken <strong>w</strong>indows, then <strong>W</strong>indows wouldn&#8217;t be so broken.</p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/12/24/the-good-the-bad-and-the-ugly/" rel="bookmark" class="crp_title">The good, the bad, and the ugly</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/" rel="bookmark" class="crp_title">Don&#8217;t Look Don&#8217;t Tell</a></li><li><a href="http://www.hornlo.org/isotropic/2009/02/18/linux-in-exile/" rel="bookmark" class="crp_title">Linux in Exile</a></li><li><a href="http://www.hornlo.org/isotropic/2008/09/14/dangerous-pencil-sharpeners/" rel="bookmark" class="crp_title">Dangerous Pencil Sharpeners</a></li><li><a href="http://www.hornlo.org/isotropic/2010/02/06/im-a-pc-and-ruining-your-battery-was-my-idea/" rel="bookmark" class="crp_title">I&#8217;m a PC, and ruining your battery was my idea.</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/02/20/the-first-twitter/" rel="bookmark" class="wherego_title">The first Twitter?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2009/02/20/broken-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What would the neighbors say?</title>
		<link>http://www.hornlo.org/isotropic/2009/02/16/what-would-the-neighbors-say/</link>
		<comments>http://www.hornlo.org/isotropic/2009/02/16/what-would-the-neighbors-say/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 13:29:06 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[humor]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=357</guid>
		<description><![CDATA[Sometimes, when I&#8217;m looking at the code of a complete stranger, I get that same, weird feeling I get when I&#8217;m creeping through my neighbour&#8217;s house. Picking up their stuff, looking through their fridge. That&#8217;s from item number 5 (Read the code from an open source project) in Leon Bambrick&#8217;s 8 ways to be a [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Sometimes, when I&#8217;m looking at the code of a complete stranger, I get that same, weird feeling I get when I&#8217;m creeping through my neighbour&#8217;s house. Picking up their stuff, looking through their fridge.</p></blockquote>
<p>That&#8217;s from item number 5 (Read the code from an open source project) in Leon Bambrick&#8217;s <a href="http://secretgeek.net/6min_program.asp">8 ways to be a better programmer in 6 minutes.</a>.  And, if you&#8217;re saying &#8220;WTF!?&#8221; after reading the list, do take a look at his &#8220;About&#8221; page.</p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2001/02/16/outrageous-spin/" rel="bookmark" class="crp_title">outrageous spin</a></li><li><a href="http://www.hornlo.org/isotropic/2001/02/23/outrageous-spin-ii/" rel="bookmark" class="crp_title">outrageous spin II</a></li><li><a href="http://www.hornlo.org/isotropic/2009/09/19/a-dark-and-stormy-night/" rel="bookmark" class="crp_title">A dark and stormy night</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/" rel="bookmark" class="crp_title">Don&#8217;t Look Don&#8217;t Tell</a></li><li><a href="http://www.hornlo.org/isotropic/2009/02/20/broken-windows/" rel="bookmark" class="crp_title">Broken Windows</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/09/19/a-dark-and-stormy-night/" rel="bookmark" class="wherego_title">A dark and stormy night</a></li><li><a href="http://www.hornlo.org/isotropic/2009/02/20/broken-windows/" rel="bookmark" class="wherego_title">Broken Windows</a></li><li><a href="http://www.hornlo.org/isotropic/2001/02/16/outrageous-spin/" rel="bookmark" class="wherego_title">outrageous spin</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2009/02/16/what-would-the-neighbors-say/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uncanny Valley of User Interface</title>
		<link>http://www.hornlo.org/isotropic/2008/12/18/uncanny-valley-of-user-interface/</link>
		<comments>http://www.hornlo.org/isotropic/2008/12/18/uncanny-valley-of-user-interface/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 13:38:34 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[uncanny valley]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=253</guid>
		<description><![CDATA[Jeff Atwood&#8217;s &#8216;Avoiding The Uncanny Valley of User Interface&#8216; caught my eye, so to speak. His contention is that &#8220;a web app that apes the conventions of a desktop application is attempting to cross the uncanny valley of user interface design&#8221;. Atwood&#8217;s post was inspired by Bill Higgins&#8217; older post &#8216;the Uncanny Valley of user [...]]]></description>
			<content:encoded><![CDATA[<p>Jeff Atwood&#8217;s &#8216;<a href="http://www.codinghorror.com/blog/archives/000869.html">Avoiding The Uncanny Valley of User Interface</a>&#8216; caught my eye, so to speak.  His contention is that &#8220;a web app that apes the conventions of a desktop application is attempting to cross the uncanny valley of user interface design&#8221;.</p>
<p>Atwood&#8217;s post was inspired by Bill Higgins&#8217; older post &#8216;<a href="">the Uncanny Valley of user interface design</a>&#8216; that says &#8220;[W]e must ensure that we design our applications to remain consistent with the environment in which our software runs. [...] I’d agree that software designers and developers generally observe this rule <em>except in the midst of a technological paradigm shift</em>. During periods of rapid innovation and exploration, it’s tempting and more acceptable to violate the expectations of a particular environment&#8221;.</p>
<p>Actually what caught my eye was Atwood&#8217;s title in my feed reader, because I&#8217;ve <a href="/isotropic/2008/03/22/bigdog-quadruped-robot/" title="BigDog Quadruped Robot">previously mentioned</a> the <a href="http://en.wikipedia.org/wiki/Uncanny_Valley">uncanny valley</a>, &#8220;a hypothesis that when robots and other facsimiles of humans look and act almost like actual humans, it causes a response of revulsion among human observers&#8221; (Wikipedia).</p>
<p>It&#8217;s an interesting play on the UV concept, replacing &#8220;creepy&#8221; with &#8220;annoying&#8221;.  I can see how this mismatch of expectations could cause a vague feeling of uneasiness/not-quite-right/frustration for someone who&#8217;s not thought much about interfaces.</p>
<p><a href="http://www.jnd.org/">Don Norman</a>&#8216;s classic <em><a href="http://www.jnd.org/books.html#33">The Psychology of Everyday Things</a></em> (reissued as <em>The Design of Everyday Things</em>), extends the idea to all the &#8220;everyday things&#8221; we humans interact with.</p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2008/03/22/bigdog-quadruped-robot/" rel="bookmark" class="crp_title">BigDog Quadruped Robot</a></li><li><a href="http://www.hornlo.org/isotropic/2008/11/29/fun-with-your-new-head/" rel="bookmark" class="crp_title">Fun With Your New Head</a></li><li><a href="http://www.hornlo.org/isotropic/2009/03/09/robot-pics/" rel="bookmark" class="crp_title">Robot Pics</a></li><li><a href="http://www.hornlo.org/isotropic/2008/03/22/cyborg-insects/" rel="bookmark" class="crp_title">Cyborg Insects</a></li><li><a href="http://www.hornlo.org/isotropic/2009/01/06/micromanagement-zombies/" rel="bookmark" class="crp_title">Micromanagement Zombies</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2010/05/24/alternate-email/" rel="bookmark" class="wherego_title">alternate email</a></li><li><a href="http://www.hornlo.org/isotropic/2009/01/06/micromanagement-zombies/" rel="bookmark" class="wherego_title">Micromanagement Zombies</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2008/12/18/uncanny-valley-of-user-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flailing Around</title>
		<link>http://www.hornlo.org/isotropic/2008/12/02/flailing-around/</link>
		<comments>http://www.hornlo.org/isotropic/2008/12/02/flailing-around/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 13:08:26 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=200</guid>
		<description><![CDATA[I think we&#8217;re leaving one metaphor on the table which more accurately reflects the way software is built in the real world: flail around randomly and pray you succeed by force of pure dumb luck. Sometimes it even works. Not very often, but just enough to confuse people who should know better into thinking they&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/media/flail.jpg" width="116" height="121" align="left" alt="" title="" style="padding-right: 1em; padding-bottom: 1em;" /> <em>I think we&#8217;re leaving one metaphor on the table which more accurately reflects the way software is built in the real world: flail around randomly and pray you succeed by force of pure dumb luck. Sometimes it even works. Not very often, but just enough to confuse people who should know better into thinking they&#8217;re smart, when what they really were is lucky.</em> <small>&#8211;<cite>Jeff Atwood, <a href="http://www.codinghorror.com/blog/archives/000987.html">Tending Your Software Garden</a>, Coding Horror</cite></small></p>
<p>So what&#8217;s your preferred software development metaphor?</p>
<p align="right"><small>image: <cite><a href="http://en.wikipedia.org/wiki/Image:Battage_%C3%A0_Fl%C3%A9au.jpg">Battage à Fléau</a>, Wikimedia Commons</cite></small></p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/01/06/micromanagement-zombies/" rel="bookmark" class="crp_title">Micromanagement Zombies</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/16/panic/" rel="bookmark" class="crp_title">Panic</a></li><li><a href="http://www.hornlo.org/isotropic/2009/07/10/generational-manifestos/" rel="bookmark" class="crp_title">Generational Manifestos</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/15/dont-look-dont-tell/" rel="bookmark" class="crp_title">Don&#8217;t Look Don&#8217;t Tell</a></li><li><a href="http://www.hornlo.org/isotropic/2009/08/15/the-face-of-skynet/" rel="bookmark" class="crp_title">The Face of SkyNet?</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2008/12/02/flailing-around/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yakity YACC</title>
		<link>http://www.hornlo.org/isotropic/2008/07/14/yakity-yacc/</link>
		<comments>http://www.hornlo.org/isotropic/2008/07/14/yakity-yacc/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 04:32:51 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[malloc]]></category>
		<category><![CDATA[yacc]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=125</guid>
		<description><![CDATA[For those of you who think you produce bug free code &#8230; As told at New Otto malloc helps spot ancient bug, &#8220;Otto Moerbeek recently found and fixed an ancient bug (some 33 years old) in yacc(1). Here is his story&#8230;.&#8221; image: Dave Pape, Bos grunniens &#8211; Syracuse Zoo.jpg, Wikimedia Commonsh/t: Bob Plankers, links for [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/media/yacc.jpg" width="100" height="81" align="left"> For those of you who think you produce bug free code &#8230;</p>
<p>As told at <a href="http://undeadly.org/cgi?action=article&#038;sid=20080708155228&#038;mode=flat">New Otto malloc helps spot ancient bug</a>, &#8220;Otto Moerbeek recently found and fixed an ancient bug (some 33 years old) in <tt>yacc(1)</tt>.  Here is his story&#8230;.&#8221;</p>
<p align="right"><small>image: <cite>Dave Pape, <a href="http://en.wikipedia.org/wiki/Image:Bos_grunniens_-_Syracuse_Zoo.jpg">Bos grunniens &#8211; Syracuse Zoo.jpg</a>, Wikimedia Commons</cite><br />h/t: <cite>Bob Plankers, <a href="http://lonesysadmin.net/2008/07/14/links-for-2008-07-14/">links for 2008-07-14</a>, <a href="http://lonesysadmin.net/" title="im in ur data centrz patchin ur serverz">The Lone Sysadmin</a></cite></small></p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2008/06/08/here-be-dragons/" rel="bookmark" class="crp_title">Here Be Dragons</a></li><li><a href="http://www.hornlo.org/isotropic/2009/05/16/panic/" rel="bookmark" class="crp_title">Panic</a></li><li><a href="http://www.hornlo.org/isotropic/2008/12/08/key-personnel-evacuation-plan/" rel="bookmark" class="crp_title">Key Personnel Evacuation Plan</a></li><li><a href="http://www.hornlo.org/isotropic/2008/09/14/dangerous-pencil-sharpeners/" rel="bookmark" class="crp_title">Dangerous Pencil Sharpeners</a></li><li><a href="http://www.hornlo.org/isotropic/2008/05/18/big-and-small/" rel="bookmark" class="crp_title">Big and Small</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2010/05/24/alternate-email/" rel="bookmark" class="wherego_title">alternate email</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2008/07/14/yakity-yacc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Filesystem Backups</title>
		<link>http://www.hornlo.org/isotropic/2008/07/07/linux-filesystem-backups/</link>
		<comments>http://www.hornlo.org/isotropic/2008/07/07/linux-filesystem-backups/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 00:36:53 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[cpio]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=120</guid>
		<description><![CDATA[Backup is an essential responsibility that comes with owning a computer, but it is more honored in the breech than in practice. Echoing what I said in MySQL Backups, some situations may require more elaborate techniques, but these scripts are &#8220;good enough&#8221; for my needs. I hope you find these scripts useful, and welcome comments, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.hornlo.org/media/fsback.jpg" width="120" height="90" align="left" alt="" title="" style="padding-right: 1em; padding-bottom: 1em;" /> <a href="http://en.wikipedia.org/wiki/Backup">Backup</a> is an essential responsibility that comes with owning a computer, but it is more honored in the breech than in practice.</p>
<p>Echoing what I said in <a href="/isotropic/2008/07/06/mysql-backups/">MySQL Backups</a>, some situations may require more elaborate techniques, but these scripts are &#8220;good enough&#8221; for my needs.  I hope you find these scripts useful, and welcome comments, critiques, or suggestions for alternative methods.  <em>Note: these are just examples.  If you use them, you do so at your own risk.  You&#8217;ll want to adjust them for your own situation.</em></p>
<p>I run these scripts ad hoc (via the <tt>at</tt> command), rather than via cron, for a couple reasons.  First, these run on my laptop, so it may be down, or the backup media may not be avalable.  Second, my personal schedule is very irregular and I prefer to back up when the system is quiescent.  I&#8217;ve found the most convenient time for incremental backups is while I&#8217;m getting ready for work.  I do full backups some time over the weekend.</p>
<p>My schedule, though not rigidly adhered to, is to run incrementals every morning.  Because the name pattern includes the day of the week, I generally have seven copies available, although not necessarily the most recent seven days.  Currently, they contain any files modified within 30 days.</p>
<p>Full backups use a similar naming scheme, which I should fix at some point.  I pick one of the weekend backups each month to preserve long term, and rename it to indicate the specific date.  I try to keep about a year&#8217;s worth of full backups available.</p>
<p>The first file backed up is <tt>/backid.txt</tt>; it is also included in the emailed logfile.  The <tt>create-backid-file</tt> script (below) dumps several pieces of information useful in recovering a system into it, such as the output of <tt>fdisk -l</tt> and <tt>/etc/fstab</tt>.  Because I use <tt>cpio</tt>, this text can be viewed directly from the archive file with <tt>less</tt>, <tt>head</tt>, or even <tt>cat</tt>.  That could be handy if you have limited resources to work with during a recovery.</p>
<p>After the backup itself completes, a verify-crc pass is made over the archive.  This may not be as assuring as doing an actual file-by-file comparison, but seems a good tradeoff in my situation between reliability and time.  An occasional file restore should be done to confirm that what you think is getting backed up really is.  I&#8217;ve also done bare-metal restores without problems using these archives.</p>
<p>The actual scripts are listed later, but first I&#8217;d like to point out a few things from the log file.</p>
<ul>
<li>the backid.txt file is included</li>
<li>line counts from the backup pass and the verify pass are included; the vast majority of the time, these are the same</li>
<li>the block count from the two passes are included; these should <em>always</em> be the same</li>
<li>the size of the archive is calculated</li>
<li>the logs are kept locally for review as well as being copied to the backup media</li>
<li>timestamps are used at important steps so I can develop a feel for how the scripts perform</li>
</ul>
<p>Here&#8217;s a sample log:</p>
<div class="geshi no text">
<ol>
<li class="li1">
<div class="de1">==============================================================================</div>
</li>
<li class="li1">
<div class="de1">Script: &nbsp; incr-backup</div>
</li>
<li class="li1">
<div class="de1">Started: &nbsp;Wed Jul &nbsp;2 06:57:03 CDT 2008</div>
</li>
<li class="li1">
<div class="de1">==============================================================================</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">[ ... deleted most of log ... ]</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Wed Jul &nbsp;2 08:14:19 CDT 2008 : testing/listing done</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">line counts from logs</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;96944 /tmp/joule-incr-Wed-v0000.log</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;96945 /tmp/joule-incr-Wed-v0000.toc</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">block counts (size=32768) from logs</div>
</li>
<li class="li1">
<div class="de1">==&gt; /tmp/joule-incr-Wed-v0000.log &lt;==</div>
</li>
<li class="li1">
<div class="de1">1145922 blocks</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">==&gt; /tmp/joule-incr-Wed-v0000.toc &lt;==</div>
</li>
<li class="li1">
<div class="de1">1145922 blocks</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">1145922 blocks @ 32768/block = 34.97 GB</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Wed Jul &nbsp;2 08:14:20 CDT 2008 : compressing logs</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Wed Jul &nbsp;2 08:14:22 CDT 2008 : moving logs to /usr/local/data/bcklogs</div>
</li>
<li class="li1">
<div class="de1">Wed Jul &nbsp;2 08:14:22 CDT 2008 : copying logs to /media/MX200702082108</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">==============================================================================</div>
</li>
<li class="li1">
<div class="de1">Script: &nbsp; &nbsp;incr-backup</div>
</li>
<li class="li1">
<div class="de1">Started: &nbsp; Wed Jul &nbsp;2 06:57:03 CDT 2008</div>
</li>
<li class="li1">
<div class="de1">Finished: &nbsp;Wed Jul &nbsp;2 08:14:22 CDT 2008</div>
</li>
<li class="li1">
<div class="de1">Usage: &nbsp; &nbsp; 34.97 GB; 96945 files/dirs</div>
</li>
<li class="li1">
<div class="de1">==============================================================================</div>
</li>
</ol>
</div>
<p>It&#8217;s kinda large because of a VMware disk image and a couple of dvd .iso files downloaded but not yet burned.</p>
<p>This is the full-backup script (<a href="/misc/fsback/full-backup.txt">text</a>).  Things to note:</p>
<ul>
<li>the <tt>DIRS</tt> variable specifies which filesystems to back up; the id file should be first in the list</li>
<li>nul-terminated paths (options <tt>-print0, -va0</tt>) are used to avoid issues with unusual filenames</li>
<li>the <tt>VOLNBR</tt> is just a holdover from tape and could be removed</li>
</ul>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/bash</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># @(#) $Id$</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BAR=</span><span class="st0">&quot;==============================================================================&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">MyScript=</span><span class="st0">&quot;`basename $0`&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">MyHost=</span><span class="st0">&quot;`hostname -s`&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">MyStart=</span><span class="st0">&quot;`date`&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">VOLNBR=</span><span class="st0">&quot;${1:-&quot;</span><span class="nu0">0000</span><span class="st0">&quot;}&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DOW=</span><span class="st0">&quot;`date +%a`&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Sun, Mon, &#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BTYPE=</span>full</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BCK=</span><span class="st0">&quot;$MyHost-$BTYPE-$DOW-v$VOLNBR.cpio&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">LOG=</span><span class="st0">&quot;$MyHost-$BTYPE-$DOW-v$VOLNBR.log&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">TOC=</span><span class="st0">&quot;$MyHost-$BTYPE-$DOW-v$VOLNBR.toc&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">WRKDIR=</span><span class="st0">&quot;/tmp&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DSTDIR=</span><span class="st0">&quot;/media/MX200702082108&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">ARCDIR=</span><span class="st0">&quot;/usr/local/data/bcklogs&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BSIZE=</span><span class="nu0">32768</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">IDFILE=</span><span class="st0">&quot;backid.txt&quot;</span> <span class="co0"># really /backid.txt</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$HOME</span><span class="sy0">/</span>bin<span class="sy0">/</span>create-backid-<span class="kw2">file</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># directories to be backed up; command option specifies not to cross filesystems</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># work is done after a &quot;cd /&quot;, so the &quot;./&quot; prefix is relative to &quot;/&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">### just for testing&#8230;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">### DIRS=&quot;$IDFILE ./boot&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DIRS=</span><span class="st0">&quot;./$IDFILE ./boot ./ ./home ./data ./usr/local ./usr ./opt ./var&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># omitted: /tmp /media</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;$BAR&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Script: &nbsp; $MyScript&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Started: &nbsp;$MyStart&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;$BAR&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Contents of /$IDFILE:&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cat</span> <span class="sy0">/</span><span class="re1">$IDFILE</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Mounted file systems:&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">df</span> -h</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : creating backup&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot; &nbsp;targets: $DIRS&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># stdout is empty (always?) when using the -O option of cpio</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># all content comes from stderr being redirected to stdout</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">cd</span> <span class="sy0">/</span> <span class="sy0">&amp;&amp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">find</span> <span class="re1">$DIRS</span> -xdev -depth -print0 <span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cpio</span> -o -va0 -H crc -C <span class="re1">$BSIZE</span> -O <span class="re1">$DSTDIR</span><span class="sy0">/</span><span class="re1">$BCK</span> <span class="sy0">&gt;</span><span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$LOG</span> <span class="nu0">2</span><span class="sy0">&gt;&amp;</span><span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : testing and listing backup&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># block count is written to stderr, but can&#39;t just send stderr to stdout</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># because the count appears to be emitted at random within stdout stream</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cpio</span> -i -vt -H crc &#8211;only-verify-crc -C <span class="re1">$BSIZE</span> -I <span class="re1">$DSTDIR</span><span class="sy0">/</span><span class="re1">$BCK</span> <span class="sy0">&gt;</span><span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span> <span class="nu0">2</span><span class="sy0">&gt;</span><span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.err</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cat</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.err <span class="sy0">&gt;&gt;</span><span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">rm</span> -f <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.err</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : testing/listing done&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;line counts from logs&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">wc</span> -l <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$LOG</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span> <span class="sy0">|</span> <span class="kw2">head</span> <span class="nu0">-2</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;block counts (size=$BSIZE) from logs&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">tail</span> -n <span class="nu0">1</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$LOG</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">fdcnt=</span>`<span class="kw2">wc</span> -l <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span> <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st0">&#39;s/^ *//&#39;</span> <span class="sy0">|</span> <span class="kw2">cut</span> -d<span class="st0">&#39; &#39;</span> -f1`</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">blkcnt=</span>`<span class="kw2">tail</span> -n <span class="nu0">1</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span> <span class="sy0">|</span> <span class="kw2">cut</span> -d<span class="st0">&#39; &#39;</span> -f1`</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">gbcnt=</span>`<span class="kw3">echo</span> <span class="st0">&quot;scale=2; $blkcnt * $BSIZE / 1024 / 1024 / 1024&quot;</span> <span class="sy0">|</span> <span class="kw2">bc</span>`</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;$blkcnt blocks @ $BSIZE/block = $gbcnt GB&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : compressing logs&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">gzip</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$LOG</span> <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : moving logs to $ARCDIR&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span> <span class="sy0">!</span> -d <span class="re1">$ARCDIR</span> <span class="br0">&#93;</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">mkdir</span> <span class="re1">$ARCDIR</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">mv</span> -f <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$LOG</span>.gz <span class="re1">$WRKDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.gz <span class="re1">$ARCDIR</span><span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">chmod</span> <span class="re2">u=</span>rw,<span class="re2">go=</span> <span class="re1">$ARCDIR</span><span class="sy0">/</span><span class="re1">$LOG</span>.gz <span class="re1">$ARCDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.gz</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : copying logs to $DSTDIR&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cp</span> <span class="re1">$ARCDIR</span><span class="sy0">/</span><span class="re1">$LOG</span>.gz <span class="re1">$ARCDIR</span><span class="sy0">/</span><span class="re1">$TOC</span>.gz <span class="re1">$DSTDIR</span><span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">MyFinish=</span><span class="st0">&quot;`date`&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;$BAR&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Script: &nbsp; &nbsp;$MyScript&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Started: &nbsp; $MyStart&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Finished: &nbsp;$MyFinish&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Usage: &nbsp; &nbsp; $gbcnt GB; $fdcnt files/dirs&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;$BAR&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></div>
</li>
</ol>
</div>
<p>The incr-backup script (<a href="/misc/fsback/incr-backup.txt">text</a>) only differs in two lines; next time I edit the scripts I&#8217;ll move the interval option to a variable.</p>
<div class="geshi no text">
<ol>
<li class="li1">
<div class="de1">$ diff full-backup incr-backup</div>
</li>
<li class="li1">
<div class="de1">16c16</div>
</li>
<li class="li1">
<div class="de1">&lt; BTYPE=full</div>
</li>
<li class="li1">
<div class="de1">&#8212;</div>
</li>
<li class="li1">
<div class="de1">&gt; BTYPE=incr</div>
</li>
<li class="li1">
<div class="de1">66c66</div>
</li>
<li class="li1">
<div class="de1">&lt; find $DIRS -xdev -depth -print0 |</div>
</li>
<li class="li1">
<div class="de1">&#8212;</div>
</li>
<li class="li1">
<div class="de1">&gt; find $DIRS -xdev -depth -mtime -30 -print0 |</div>
</li>
</ol>
</div>
<p>Finally, the create-backid-file (<a href="/misc/fsback/create-backid-file.txt">text</a>).  I&#8217;ve stripped out the extra noise from the script for display in this post.  Select the text link to get the whole thing.  The <tt>grub.conf</tt> (or lilo) should probably be added as well.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">uname</span> -a</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">cat</span> <span class="sy0">/</span>etc<span class="sy0">/</span>fstab</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">df</span> -h</div>
</li>
<li class="li1">
<div class="de1">fdisk -l</div>
</li>
<li class="li1">
<div class="de1">chkconfig &#8211;list</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">ps</span> -ef</div>
</li>
</ol>
</div>
<p>Aside, check out the full-size version of the lead image &#8212; it&#8217;s high res and quite interesting, along with the Wikipedia article <a href="http://en.wikipedia.org/wiki/Hard_disk_drive">Hard disk drive</a> where I found it.</p>
<p align="right"><small>image: <cite>Paul R. Potts, <a href="http://en.wikipedia.org/wiki/Image:SixHardDriveFormFactors.jpg">SixHardDriveFormFactors.jpg</a>, Wikimedia Commons</cite></small></p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2008/07/06/mysql-backups/" rel="bookmark" class="crp_title">MySQL Backups</a></li><li><a href="http://www.hornlo.org/isotropic/2009/03/04/upgrade-to-wordpress-271/" rel="bookmark" class="crp_title">Upgrade to WordPress 2.7.1</a></li><li><a href="http://www.hornlo.org/isotropic/2008/09/07/research-desktop-workspace/" rel="bookmark" class="crp_title">Research Desktop Workspace</a></li><li><a href="http://www.hornlo.org/isotropic/2009/04/04/need-to-know/" rel="bookmark" class="crp_title">Need to know</a></li><li><a href="http://www.hornlo.org/isotropic/2008/04/13/quick-and-dirty-perl-001/" rel="bookmark" class="crp_title">Quick and Dirty Perl &#8211; #001</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/04/04/need-to-know/" rel="bookmark" class="wherego_title">Need to know</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2008/07/07/linux-filesystem-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Backups</title>
		<link>http://www.hornlo.org/isotropic/2008/07/06/mysql-backups/</link>
		<comments>http://www.hornlo.org/isotropic/2008/07/06/mysql-backups/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 14:17:08 +0000</pubDate>
		<dc:creator>hornlo</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.hornlo.org/isotropic/?p=118</guid>
		<description><![CDATA[Even if you consistently back up your filesystem, you should also back up your databases separately, using an appropriate tool to maintain their relational integrity and to provide for recovery independent of the filesystem. MySQL is a pervasive, lightweight RDBMS that is used with popular applications such as WordPress and Bugzilla. The mysqldump utility which [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.hornlo.org/media/mysql.gif" width="125" height="68" align="left" alt="" title="" style="padding-right: 1em; padding-bottom: 1em;" /> Even if you consistently back up your filesystem, you should also back up your databases separately, using an appropriate tool to maintain their relational integrity and to provide for recovery independent of the filesystem.</p>
<p><a href="http://www.mysql.com/">MySQL</a> is a pervasive, lightweight <acronym title="Relational Database Management System">RDBMS</acronym> that is used with popular applications such as WordPress and Bugzilla.  The <tt>mysqldump</tt> utility which comes with MySQL provides a quick and simple way to create database backups.</p>
<p>While some situations my require more elaborate techniques, these scripts, using mysqldump, should be fine for the most common uses.  They are run nightly via cron and keep a week&#8217;s worth of backups.  <em>Note: these are just examples.  If you use them, you do so at your own risk.  You&#8217;ll want to adjust them for your own situation.</em></p>
<p>This first script (<a href="/misc/mysql/mysql-backup-local.txt">text</a>) runs on my laptop.  Because it accesses the local server, has full permissions, and the databases are small, it locks and backs up everything at once.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/bash</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># @(#) $Id$</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BCKDIR=</span><span class="re1">$HOME</span><span class="sy0">/</span>backups<span class="sy0">/</span>mysql</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BCKFILE=</span><span class="st0">&quot;mysql-backup-`date +%a`.sql&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span> <span class="sy0">!</span> -d <span class="re1">$BCKDIR</span> <span class="br0">&#93;</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">mkdir</span> -p <span class="re1">$BCKDIR</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : starting backup&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">mysqldump <span class="sy0">&gt;</span> <span class="re1">$BCKDIR</span><span class="sy0">/</span><span class="re1">$BCKFILE</span> &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;opt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;allow-keywords &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;comments &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;create-options &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;disable-keys &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;flush-logs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;flush-privileges &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;lock-all-tables &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;all-databases</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : completed&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">ls</span> -lh <span class="re1">$BCKDIR</span><span class="sy0">/</span><span class="re1">$BCKFILE</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># end</span></div>
</li>
</ol>
</div>
<p>This second script (<a href="/misc/mysql/mysql-backup-remote.txt">text</a>) runs on my blog host; the actual database is on another host.  It differs from the previous script in that the <tt>flush-logs</tt> and <tt>lock-all-tables</tt> can&#8217;t be used, only a single database is backed up, and a password is required.  I&#8217;ve also added the <tt>uptime</tt> command so that I can see how the server is performing when backups are run.  <em>Note: I don&#8217;t recommend embedding passwords in scripts, but it makes the example simpler.</em></p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/bash</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># @(#) $Id$</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DBNAME=</span>cutedbname</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DBHOST=</span>mysql.example.com</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">DBPASS=</span>noway</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BCKDIR=</span><span class="re1">$HOME</span><span class="sy0">/</span>backups<span class="sy0">/</span>mysql</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">BCKFILE=</span><span class="st0">&quot;$DBNAME-`date +%a`.sql&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">uptime</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span> <span class="sy0">!</span> -d <span class="re1">$BCKDIR</span> <span class="br0">&#93;</span> <span class="sy0">&amp;&amp;</span> <span class="kw2">mkdir</span> -p <span class="re1">$BCKDIR</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : starting backup&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># I don&#39;t have RELOAD privs, so can&#39;t use</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &nbsp; &#8211;flush-logs</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># &nbsp; &#8211;lock-all-tables</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">mysqldump <span class="sy0">&gt;</span> <span class="re1">$BCKDIR</span><span class="sy0">/</span><span class="re1">$BCKFILE</span> &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;<span class="re2">host=</span><span class="re1">$DBHOST</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;opt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;allow-keywords &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;comments &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;create-options &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;disable-keys &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &#8211;<span class="re2">password=</span><span class="re1">$DBPASS</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re1">$DBNAME</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;`date` : completed&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">chmod</span> <span class="re2">u=</span>rw,<span class="re2">g=</span>,<span class="re2">o=</span> <span class="re1">$BCKDIR</span><span class="sy0">/</span><span class="re1">$BCKFILE</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">ls</span> -lh <span class="re1">$BCKDIR</span><span class="sy0">/</span><span class="re1">$BCKFILE</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">uptime</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># end</span></div>
</li>
</ol>
</div>
<p>In both cases, cron emails the log file to me.  A typical message looks like this:</p>
<div class="geshi no text">
<ol>
<li class="li1">
<div class="de1">&nbsp;04:13:02 up 7 days, 19:24, &nbsp;1 user, &nbsp;load average: 1.68, 2.60, 2.87</div>
</li>
<li class="li1">
<div class="de1">Fri Jul &nbsp;4 04:13:02 CDT 2008 : starting backup</div>
</li>
<li class="li1">
<div class="de1">Fri Jul &nbsp;4 04:13:02 CDT 2008 : completed</div>
</li>
<li class="li1">
<div class="de1">-rw&#8212;&#8212;- &nbsp;1 xuser xgroup 572K 2008-07-04 04:13 /home/xuser/backups/mysql/cutedbname-Fri.sql</div>
</li>
<li class="li1">
<div class="de1">&nbsp;04:13:02 up 7 days, 19:24, &nbsp;1 user, &nbsp;load average: 1.68, 2.60, 2.87</div>
</li>
</ol>
</div>
<p>I periodically <tt>rsync</tt> my entire remote site to local storage &#8212; having the backups on the same remote host as your live data won&#8217;t do you any good if your host loses a disk (and have stale or corrupted backups), or falls off the &#8216;Net.  Of course my own filesystem backups take care of having long term, off-the-machine backups of my local stuff.  I&#8217;ll discuss the <a href="/isotropic/2008/07/07/linux-filesystem-backups/" title="Linux Filesystem Backups">filesystem backups</a> in a future post.</p>
<p>I hope you find these scripts useful, and welcome comments, critiques, or suggestions for alternative methods.</p>
<p><small><em>Update (7/7):</em> added link to filesystem backups</small></p>
<div id="crp_related"><h3> Related Posts (in theory, but probably not):</h3><ul><li><a href="http://www.hornlo.org/isotropic/2009/03/04/upgrade-to-wordpress-271/" rel="bookmark" class="crp_title">Upgrade to WordPress 2.7.1</a></li><li><a href="http://www.hornlo.org/isotropic/2008/07/07/linux-filesystem-backups/" rel="bookmark" class="crp_title">Linux Filesystem Backups</a></li><li><a href="http://www.hornlo.org/isotropic/2009/03/08/how-to-list-comment-spam-ip-addresses/" rel="bookmark" class="crp_title">How to list comment spam IP addresses</a></li><li><a href="http://www.hornlo.org/isotropic/2009/09/08/back-up-your-stuff/" rel="bookmark" class="crp_title">Back. Up. Your. Stuff.</a></li><li><a href="http://www.hornlo.org/isotropic/2008/09/07/research-desktop-workspace/" rel="bookmark" class="crp_title">Research Desktop Workspace</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div><div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.hornlo.org/isotropic/2008/07/06/mysql-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

