<?xml version="1.0"?>
<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/"
	>
   <channel>
      <pubDate>Thu, 4 Dec 2008 04:38:36 GMT</pubDate>
      <lastBuildDate>Thu, 4 Dec 2008 04:38:36 GMT</lastBuildDate>
      <language>en</language>
      <docs>http://www.rssboard.org/rss-specification</docs>
      <title>CrunchBang ~ shell</title>
      <link>http://crunchbang.org/tags/shell/</link>
      <description>Code, Design &amp; GNU/Linux</description>

<item>
    <title>Wicked Cool Shell Scripts</title>
    <link>http://crunchbang.org/archives/2008/02/17/wicked-cool-shell-scripts/</link>
    <pubDate>Sun, 17 Feb 2008 07:41:45 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2008/02/17/wicked-cool-shell-scripts/</guid>
    <description><![CDATA[
    <p>I&#39;ve not read the book, but the <a href="http://www.intuitive.com/wicked/index.shtml " title="Wicked Cool Shell Scripts">Wicked Cool Shell Scripts</a> site and its example shell scripts are, erm, wicked cool. The site offers a whole host of scripts, some of which could quite easily be adapted/hacked into useful tools. If you&#39;re remotely interested in Shell scripting, you should take a look, even people with scripting experience might learn a thing or two.</p>

<p>URL: <a href="http://www.intuitive.com/wicked/index.shtml " title="Wicked Cool Shell Scripts">http://www.intuitive.com/wicked/index.shtml</a></p>

<p>Download the script library: <a href="http://crunchbang.org/misc/wicked-cool-shell-scripts.tgz " title="Wicked Cool Shell Scripts">wicked-cool-shell-scripts.tgz</a></p>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/code/" title="Browse all posts tagged with &#8220;code&#8221;">code</a>, <a href="http://crunchbang.org/tags/linux/" title="Browse all posts tagged with &#8220;linux&#8221;">linux</a>, <a href="http://crunchbang.org/tags/programming/" title="Browse all posts tagged with &#8220;programming&#8221;">programming</a>, <a href="http://crunchbang.org/tags/shell/" title="Browse all posts tagged with &#8220;shell&#8221;">shell</a></p>
    ]]></description>
</item>

<item>
    <title>Bash Script: MySQL Backup</title>
    <link>http://crunchbang.org/archives/2007/11/18/bash-script-mysql-backup/</link>
    <pubDate>Sun, 18 Nov 2007 22:11:11 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2007/11/18/bash-script-mysql-backup/</guid>
    <description><![CDATA[
    <p><em>I thought that it might be a good idea to start posting a few of my scripts; it&#39;ll be handy to have them on my site for future reference. Also, I learn  a lot by reading example scripts &#8212; I guess others might be able to learn from mine.</em></p>

<p>I wrote the following Bash script to perform a backup of a remote MySQL database. The script first connects via SSH and performs a MySQL dump, saving the results to file. It then connects via SFTP and downloads the file. Once the file has been downloaded, it restores the database to my local MySQL server.</p>

<p>It is quite a simple Bash script and it should be fairly straightforward to follow.</p>

<pre><code>#!/bin/sh
# Settings
#############################
REMOTEHOST="example.com"
REMOTEBACKUPDIR="backup/sql"
SQLHOST="localhost"
SQLDB="database_name"
SQLUSER="username"
SQLPASS="password"
SQLFILE="database_name.sql"
LOCALBACKUPDIR="backup/sql"
#############################
# Start main
echo "* Connecting via SSH..."
ssh $REMOTEHOST &lt;&lt;**
echo "* Performing SQL dump..."
if [ -d $REMOTEBACKUPDIR ]; then
    cd $REMOTEBACKUPDIR
else
    mkdir $REMOTEBACKUPDIR
    cd $REMOTEBACKUPDIR
fi
mysqldump -h $SQLHOST --user="$SQLUSER" --password="$SQLPASS" $SQLDB &gt; $SQLFILE
echo "* Closing SSH connection..."
exit
**
cd ~
if [ -d $LOCALBACKUPDIR ]; then
    cd $LOCALBACKUPDIR
else
    mkdir $LOCALBACKUPDIR
    cd $LOCALBACKUPDIR
fi
echo "* Connecting via SFTP..."
sftp $REMOTEHOST &lt;&lt;**
cd $REMOTEBACKUPDIR
get $SQLFILE
exit
**
echo "* Restoring SQL dump to local server..."
mysql --user "$SQLUSER" --password="$SQLPASS" $SQLDB &lt; $SQLFILE
echo "* SQL backup complete."
cd ~
exit 0
</code></pre>

<h3>Notes</h3>

<ol>
<li>For automation purposes, this script assumes that SSH and SFTP have been configured for automatic login. See &#34;<a href="http://crunchbang.org/archives/2007/10/19/creating-privatepublic-ssh-keys/ " title="Creating Private/Public SSH Keys">Creating Private/Public SSH Keys</a>&#34;</li>
<li>It also assumes there is a mirrored MySQL server and user account running on the local machine.</li>
<li>The script can be automated using <a href="http://crunchbang.org/archives/2007/10/26/howto-setup-a-crontab-file/ " title="Howto Set-up a Crontab File">Crontab</a>.</li>
<li>Lacks any error handling and/or logging!?</li>
<li>I&#39;ve worked with some commercial hosting providers who do not grant table locking privileges to their MySQL users &#8212; table locking can be bypassed by adding the &#34;<code>--skip-lock-tables</code>&#34; option to the &#34;<code>mysqldump</code>&#34; command. <em>Use with caution.</em>   </li>
</ol>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/code/" title="Browse all posts tagged with &#8220;code&#8221;">code</a>, <a href="http://crunchbang.org/tags/linux/" title="Browse all posts tagged with &#8220;linux&#8221;">linux</a>, <a href="http://crunchbang.org/tags/programming/" title="Browse all posts tagged with &#8220;programming&#8221;">programming</a>, <a href="http://crunchbang.org/tags/shell/" title="Browse all posts tagged with &#8220;shell&#8221;">shell</a></p>
    ]]></description>
</item>

 </channel>
</rss>