<?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>LiveAverage &#187; mysql</title>
	<atom:link href="http://liveaverage.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://liveaverage.com</link>
	<description>I can&#039;t afford to live any other way.</description>
	<lastBuildDate>Tue, 08 May 2012 21:26:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Bashing MySQL Dumps</title>
		<link>http://liveaverage.com/features/coding/bashing-mysql-dumps/</link>
		<comments>http://liveaverage.com/features/coding/bashing-mysql-dumps/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:45:14 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dumps]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=9</guid>
		<description><![CDATA[A quick set of scripts to dump specified databases from MySQL and mail a copy of the log to a specified e-mail address (requires Per]]></description>
			<content:encoded><![CDATA[<p>A quick set of batch scripts I wrote up (two of the three scripts, anyway) for dumping all of my (specified) MySQL databases into an archive for backup. The log mailing (<strong>emailsql.pl</strong>)requires Perl and the MIME:Lite module to correctly function. I&#8217;ve also utilized a wrapper script so the log outputs to a separate file [to be mailed]. There&#8217;s also a &#8216;dummy&#8217; log file I use in my crontab file, though this isn&#8217;t really necessary:</p>
<p><span id="more-9"></span></p>
<p><span style="color: #800000;"><strong>mysqlbackupwrapper.sh</strong></span></p>
<pre class="brush: bash;">
#!/bin/bash
#Wrapper script used to call the primary backup script and output to a specified file
sh /home/administrator/scripts/mysqlbackups &gt; /home/administrator/scripts/sql.backup.log 2&gt;&amp;1
</pre>
<p><span style="color: #800000;"><strong>mysqlbackup.sh</strong></span>:</p>
<pre class="brush: bash;">
#!/bin/sh
#Timestamp for your logs:
date

#Dump the databases - Make sure to specify your root or user password following the -p switch:
mysqldump -uroot -p --opt intraforum &gt; /home/administrator/scripts/sqldata/intra_apdforum.sql
mysqldump -uroot -p --opt joomla_intranet &gt; /home/administrator/scripts/sqldata/intra_intranet.sql
mysqldump -uroot -p --opt mysql &gt; /home/administrator/scripts/sqldata/intra_mysql.sql
tar -zcvf /home/administrator/scripts/sqldata.tgz /home/administrator/scripts/sqldata/*.sql
echo
echo &quot;Backup completed successfully for: &quot;
echo
echo &quot;MySQL - PHPbb3 Forum&quot;
echo &quot;MySQL - Joomla 1.0.X Intranet&quot;
echo &quot;MySQL - Intranet MySQL Tables&quot;
echo
echo &quot;Copying to SERVER.yourdomain.local . . . .&quot;
echo

#Use SCP to transfer to file so you can verify successful backups -- Make sure to use identity/keys for SCP instead of a password:
scp -v -i /home/administrator/identity /home/administrator/scripts/sqldata.tgz administrator@this.host:/backup/sqldata_backup.tgz

perl /home/administrator/scripts/emailsql.pl
</pre>
<p><span style="color: #800000;"><strong>emailsql.pl (I did not write this one)</strong></span>:</p>
<p>Instead of just sending the text of the log file, this script attaches the file and sends the message:</p>
<pre class="brush: bash;">

#!/usr/bin/perl -w
use MIME::Lite;

$msg = MIME::Lite-&gt;new(
From    =&gt; 'Backup Log',
To      =&gt; 'liveaverage@yourdomain.org',
Subject =&gt; 'MySQL Data Backup - Intranets',
Type    =&gt; 'text/plain',
Data    =&gt; &quot;See the attached log for details on the most recent MySQL Database Dumps.&quot;);

$msg-&gt;attach(
Type       =&gt;'text/plain',
Path       =&gt;'/home/administrator/scripts/sql.backup.log',
Filename   =&gt;'sql.backup.log',
Disposition        =&gt;'attachment');

$msg-&gt;send;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/bashing-mysql-dumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
