<?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; Coding</title>
	<atom:link href="http://liveaverage.com/category/features/coding/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:40:12 +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>Managing backup retention&#8230; with one line of Powershell</title>
		<link>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/</link>
		<comments>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 18:09:08 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=401</guid>
		<description><![CDATA[<p>Ok, I used four lines, but my needs for retention might be a bit more complex than most. I also spaced each pipeline command, so it looks longer than it should, but readability is important. Additionally, there&#8217;s a good half-page of comments in the script than can safely be ignored, unless you want to know [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I used four lines, but my needs for retention might be a bit more complex than most. I also spaced each pipeline command, so it looks longer than it should, but readability is important. Additionally, there&#8217;s a good half-page of comments in the script than can safely be ignored, unless you <em>want</em> to know what was going through my mind. Most of these related directly to my desired retention periods.</p>
<p>For testing purposes, the last two &#8220;lines&#8221; only print out the listing of files that would be deleted.</p>
<p><span id="more-401"></span></p>
<pre class="brush: bash; title: ; notranslate">
Param ($backupDir)

######
# Handle 30-day backup recyclables first (no directory recursion since each backup is in its own directory)
# The current backup schedule performs weekly configuration backups with 1-month retention.
######

Get-ChildItem &quot;$backupDir\backup_data&quot; | `
`
Where-Object {(($_.FullName -match &quot;configuration_isxpr01_&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddMonths(-1)) ) )} | `
`
ForEach-Object {`
                    Out-File -filepath &quot;$backupDir\log&quot; -inputobject $((Get-Date -format g) + &quot;Removing &quot; + $_.FullName + &quot; from &quot; + $_.CreationTime) -append`
                    Remove-Item $_.FullName -recurse}

######
# Handle 7-day backup recyclables next (no directory recursion since each backup is in its own directory)
# The current backup schedule performs weekly configuration backups with 1-week retention.
# No &quot;overwrite option available, so this script manages removal
######

Get-ChildItem &quot;$backupDir\backup_data&quot; | `
`
Where-Object {(($_.FullName -match &quot;backup_isxpr01_&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddDays(-7)) ) )} | `
`
ForEach-Object {(Remove-Item $_.FullName -recurse)}

######
# Handle daily trend data recyclables next (use recursion parameter).
# The current daily trend export schedule requires 1-month retention for 24-hr trend data.
######

Get-ChildItem -include *.zip -recurse -path &quot;$backupDir\trend_data_export&quot; | `
`
Where-Object {(($_.FullName -match &quot;24-hr&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddMonths(-1)) ) )} | `
`
ForEach-Object {($_.FullName)}

######
# Handle monthly trend data recyclables next (use recursion parameter).
# The current monthly trend export schedule requires 5-year retention for 30-day trend data.
######

Get-ChildItem -include *.zip -recurse -path &quot;$backupDir\trend_data_export&quot; | `
`
Where-Object {(($_.FullName -match &quot;30-day&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddYears(-5)) ) )} | `
`
ForEach-Object {($_.FullName)}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenFiler errors that only I seemed to experience&#8230;</title>
		<link>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/</link>
		<comments>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 16:51:03 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Infrastructure Management]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=378</guid>
		<description><![CDATA[<p>Well, I&#8217;ve finally deployed some production Openfiler ESA 2.99.1 machines as home-brew iSCSI boxes, primarily used for backups or low-stress virtual storage. Yes, they&#8217;re great &#8212; my basic write speeds on a Core 2 Duo box (recycled Dell Precision 390 workstation with 2GB of RAM and a single 1TB drive *no* RAID):</p> <p>I&#8217;m pretty happy with [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve finally deployed some production Openfiler ESA 2.99.1 machines as home-brew iSCSI boxes, primarily used for backups or low-stress virtual storage. Yes, they&#8217;re great &#8212; my basic write speeds on a Core 2 Duo box (recycled Dell Precision 390 workstation with 2GB of RAM and a single 1TB drive *no* RAID):</p>
<pre class="brush: bash; title: ; notranslate">
administrator@mail:/backup-iscsi$ sudo dd if=/dev/zero of=garbage bs=131072 count=20000
20000+0 records in
20000+0 records out
2621440000 bytes (2.6 GB) copied, 40.8493 s, 64.2 MB/s
</pre>
<p>I&#8217;m pretty happy with that. What I&#8217;m not please with is a 56MB log (/var/log/secure) filled with strange messages:</p>
<pre class="brush: bash; title: ; notranslate">Jul 26 12:25:46 e0-002 sudo: openfiler : TTY=unknown ; PWD=/opt/openfiler/var/www/htdocs ; USER=root ; COMMAND=/usr/bin/uptime
Jul 26 12:25:46 e0-002 sudo: PAM unable to dlopen(/lib64/security/pam_gnome_keyring.so)
Jul 26 12:25:46 e0-002 sudo: PAM [error: /lib64/security/pam_gnome_keyring.so: cannot open shared object file: No such file or directory]
Jul 26 12:25:46 e0-002 sudo: PAM adding faulty module: /lib64/security/pam_gnome_keyring.so</pre>
<p>Okay, so the first message isn&#8217;t strange. In fact, it&#8217;s normal. But I couldn&#8217;t figure out why a non-GUI (yes, it has a web interface, but no default window manager) distro was trying to load the Gnome keyring shared object. I still don&#8217;t know why. What I do know is how to get rid of this message:</p>
<ol>
<li>Verify which PAM files reference this shared object:</li>
<ol>
<li>
<pre class="brush: bash; title: ; notranslate">[root@e0-002 pam.d]# cd /etc/pam.d/
[root@e0-002 pam.d]# grep -i -n 'pam_gnome_keyring.so' *
system-auth:5:# FL: Have (patched) pam_gnome_keyring.so grab the password before pam_unix.so
system-auth:6:auth        optional      pam_gnome_keyring.so
system-auth:16:password    optional      pam_gnome_keyring.so</pre>
</li>
</ol>
<li>In this instance, the &#8216;system-auth&#8217; file contained these troublesome pam_gnome_keyring.so entries.</li>
<li>Fire-up your favorite text editor and comment those lines.</li>
<li>Reboot &amp; enjoy a log without an absurd amount of irrelevant errors.</li>
</ol>
<div><a title="The original thread mentioning the problem." href="https://lists.openfiler.com/viewtopic.php?id=6228" target="_blank">I found this referenced <em>once</em> on the OpenFiler forums</a>, but no answer or explanation. I hope this helps someone else that might experience a similar problem.</div>
<div>I&#8217;ll also be doing a write-up related to OpenFiler volume backups with LVM snapshots.</div>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add &#8216;Submitted Tickets&#8217; Listing Page for Joomla! RSTickets</title>
		<link>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/</link>
		<comments>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 17:15:21 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=202</guid>
		<description><![CDATA[<p></p> <p>If you haven&#8217;t heard, <a title="Check out the RSTickets! extension from RSJoomla!" href="http://www.rsjoomla.com/joomla-components/rstickets.html" target="_blank">RSTickets!</a> is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Joomla!" src="http://cdn.joomla.org/images/logo.png" alt="" width="235" height="46" /></p>
<p>If you haven&#8217;t heard, <a title="Check out the RSTickets! extension from RSJoomla!" href="http://www.rsjoomla.com/joomla-components/rstickets.html" target="_blank">RSTickets!</a> is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! 1.5+ framework that I would personally recommend. Unfortunately, it&#8217;s still under development and lacks certain features that one may desire, such as a read-only listing page that displays tickets already submitted to you or your department.</p>
<p><span id="more-202"></span><strong>My Problem:</strong></p>
<p>I noticed internal network clients were submitting several duplicate tickets related to a shared problem (i.e. printer trouble, network outages, etc.). I couldn&#8217;t blame them since they couldn&#8217;t view previously submitted tickets, so I decided to create a quick + dirty page that pulls <em>&#8220;open,&#8221; </em>or <em>&#8220;on-hold,&#8221;</em> tickets from a specific department&#8217;s table of submitted [active] tickets and displays them on a Joomla! article page (using the Sourcerer plug-in to execute custom PHP with {source} tags). Pasting this code into an article without the Sourcerer plug-in [or some sort of plug-in for executing PHP] <em>will do nothing. </em>Also note the <em>include</em> file for making a raw connection to your MySQL database. This is required (and should be stored in a directory with the appropriate permissions to prevent outside read access).</p>
<p>If you&#8217;d like to simply list the number (amount) of tickets (open, closed, on-hold) for <em>all</em> departments, you might want to <a title="Try RSJoomla!'s RSTicket Module for a quick count of all tickets." href="http://www.rsjoomla.com/customer-support/forum/38-rstickets/7805-joomla-module-for-rstickets.html" target="_blank">check the unreleased version of RSJoomla!&#8217;s RSTicket Module.</a></p>
<pre class="brush: php; title: ; notranslate">
{source}
&lt;?php

include (&quot;includes/connect_custom.php&quot;);

$result2 = mysql_query(&quot;SELECT * FROM jos_rstickets_tickets WHERE DepartmentId=3 AND (TicketStatus='open' OR TicketStatus='on-hold') ORDER BY TicketTime ASC&quot;) or die(mysql_error());

echo '&lt;br /&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;Please check the open, pending, or on-hold tickets listed below before submitting a support ticket. The list below can be utilized as an informal gauge for IT response times. If a duplicate support ticket is submitted, you may cancel it yourself or it will be deleted by the IT Department upon review. Thank you for your cooperation.&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;font-size: 16px;font-weight: bold;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;SUBMITTED SUPPORT TICKETS:&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;text-align:left; padding-bottom:7px;&quot;&gt;&lt;strong&gt;Submitted:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Username:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Ticket Code:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Subject:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Status:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Priority:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

while($row = mysql_fetch_array($result2))

{

$custid =  $row['CustomerId'];
$userquery= mysql_query(&quot;SELECT name FROM jos_users WHERE id=$custid&quot;) or die(mysql_error());

$username = mysql_fetch_array($userquery);

echo '&lt;tr style=&quot;font-size: 10px;vertical-align:top;&quot;&gt;&lt;td style=&quot;width: 102px; overflow: hidden;padding: 3px -10px 3px 3px;&quot;&gt;' . date(&quot;Y-m-d H:m&quot;, $row['TicketTime']) .  '&lt;/td&gt;&lt;td&gt;' . $username['name'] . '&lt;/td&gt;&lt;td&gt;' . $row['TicketCode'] . '&lt;/td&gt;&lt;td style=&quot;width: 235px; overflow: hidden;&quot;&gt;' . $row['TicketSubject'] . '&lt;/td&gt;&lt;td&gt;' . strtoupper($row['TicketStatus']) . '&lt;/td&gt;';

if ($row['TicketPriority']=='high'){

echo '&lt;td style=&quot;background-color: red; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='normal'){

echo '&lt;td style=&quot;background-color: blue; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='low'){

echo '&lt;td style=&quot;background-color: yellow; font-color: black; font-weight: bold;padding-left: 5px;&quot;&gt;';}

echo strtoupper($row['TicketPriority']) . '&lt;/td&gt;&lt;/tr&gt;';

}

echo '&lt;tr&gt;&lt;td style=&quot;font-size:16px; padding-top: 20px; padding-bottom: 20px&quot; colspan=&quot;6&quot;&gt;&lt;strong&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;&lt;img src=&quot;images/M_images/onsite_support1.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;SUBMIT A NEW SUPPORT TICKET&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;br /&gt;';

?&gt;
{/source}
</pre>
<p><strong>connect_custom.php :</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

// Script:	connect_custom.php
// Author:	JR
// Date:	20080218
// Use:	    Utilized for custom DB connections to our current database for Fabrik Forms + Joomla 1.5

$hostname=&quot;localhost&quot;;
$mysql_login=&quot;thedude&quot;;
$mysql_password=&quot;sumpasswordhere&quot;;
$database=&quot;datablah&quot;;

if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
die(&quot;Can't connect to database server.&quot;);
}else{
if (!(mysql_select_db(&quot;$database&quot;,$db))){
die(&quot;Can't connect to database.&quot;);
}
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Altermime, Postfix/Zimbra, and Headaches</title>
		<link>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/</link>
		<comments>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 19:43:11 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=109</guid>
		<description><![CDATA[<p>EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains.</p> <p>I had the pleasure of applying mandatory disclaimers [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains.</em></p></blockquote>
<p>I had the pleasure of applying mandatory disclaimers to all [outbound] emails at my workplace today&#8230; ~Joy~ &#8230; I had the assumption it&#8217;d be rather easy, but Altermime and Postfix were a bit finicky to work with. After editing the <strong>master.cf</strong> I ended up customizing my own &#8216;disclaimer&#8217; shell script.</p>
<p><span id="more-109"></span></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail

# Exit codes from
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap &quot;rm -f in.$$&quot; 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat &gt; in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

# Verify this mail is not incoming or internal-only
# We don't need disclaimers for either one of these cases.

# Debug:
#echo &quot;output: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt

#Grab the from address:

from_address=`grep -m 1 &quot;From:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`

#Verify whether your domain is in the from address.
#If it is, proceed to distinguish WHICH domain is sending outgoing mail and tag it appropriately:
#If not, then that would be incoming mail, so leave it alone:

#Additional (else if) conditional checks will be added to determine if the email is inner-office comm:
# to_address= `grep -m 1 &quot;To:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`
# if [[ $from_address == *domain* &amp;&amp; to_address == *domain* ]]; then ....
#
# This additional condition requires more debugging...

if [[ $from_address == *domain* ]]; then

# Debug:
#echo
#echo &quot;FROM: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt
#echo &quot;THIS GETS ALTERMIMED&quot; &gt;&gt; /tmp/tempoutput.txt
#echo

#Check to see which domain is sending outgoing email,
#then tag it with the appropriate disclaimer:

if [[ $from_address == *subdomain.domain* ]]; then

# Debug		echo &quot;THIS GETS APDD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }
else
# Debug		echo &quot;THIS GETS COAD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }

fi
fi

# Might need to remove -i switch for truncation problems depending on your MTA version...

$SENDMAIL -i &quot;$@&quot; &lt; in.$$

exit $?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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; title: ; notranslate">
#!/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; title: ; notranslate">
#!/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; title: ; notranslate">

#!/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>
		<item>
		<title>Perl my way to happiness</title>
		<link>http://liveaverage.com/features/coding/perl-my-way-to-happiness/</link>
		<comments>http://liveaverage.com/features/coding/perl-my-way-to-happiness/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 19:00:49 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[perl zimbra zmprov provisioning]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=4</guid>
		<description><![CDATA[<p>If only everything was as easy &#38; straight-forward as account provisioning in Zimbra:</p>]]></description>
			<content:encoded><![CDATA[<p>If only everything was as easy &amp; straight-forward as account provisioning in Zimbra:</p>
<pre class="brush: bash; title: ; notranslate">!/usr/bin/perl

# ZCS IMPORT SCRIPT
#       Provided by : ZCS Wiki
#       Modified by : J.R.
#       Last Change : 2008.04.09
#
# Lookup the valid COS (Class of Service) ID in the interface or like this
my $cosid = `su - zimbra -c 'zmprov gc apd |grep zimbraId:'`;
$cosid =~ s/zimbraId:\s*|\s*$//g;

while (&lt;&gt;) {
chomp;

# CHANGE ME: To the actual fields you use in your CSV file
my ($email, $password, $first, $last) = split(/\,/, $_, 4);

my ($uid, $domain) = split(/@/, $email, 2);

print qq{ca $uid\@$domain $password\n};
print qq{ma $uid\@$domain zimbraCOSid &quot;$cosid&quot;\n};
print qq{ma $uid\@$domain givenName &quot;$first&quot;\n};
print qq{ma $uid\@$domain sn &quot;$last&quot;\n};
print qq{ma $uid\@$domain cn &quot;$uid&quot;\n};
print qq{ma $uid\@$domain displayName &quot;$first $last&quot;\n};

#Set the user's reply or canonical address
print qq{ma $uid\@$domain zimbraMailCanonicalAddress $uid\@cityof*****.org\n};

#Add e-mail account alias for multiple domains
#Verify domain is correctly working for provisioning aliases

print qq{aaa $uid\@$domain $uid\@cityof*****.com\n};

#Add all users to a general distribution list and terminate
#Add multiple distro-lists if desired
print qq{adlm dept.all\@cityof*****.org $uid\@cityof*****.org\n};
print qq{\n};

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/perl-my-way-to-happiness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

