<?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>cenolan.com &#187; Amazon S3</title>
	<atom:link href="http://www.cenolan.com/tag/amazon-s3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cenolan.com</link>
	<description>What you looking at?</description>
	<lastBuildDate>Sun, 14 Jun 2009 20:03:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How-To: Automated incremental daily backups to Amazon S3 using Duplicity</title>
		<link>http://www.cenolan.com/2008/12/how-to-incremental-daily-backups-amazon-s3-duplicity/</link>
		<comments>http://www.cenolan.com/2008/12/how-to-incremental-daily-backups-amazon-s3-duplicity/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 16:58:30 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[CentOS 5.x]]></category>
		<category><![CDATA[Fedora 10]]></category>
		<category><![CDATA[Fedora 8]]></category>
		<category><![CDATA[Fedora 9]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Yellow Dog Linux]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[duplicity]]></category>

		<guid isPermaLink="false">http://www.cenolan.com/?p=54</guid>
		<description><![CDATA[This guide shows how to use Amazon S3 with duplicity to make secure GPG encrypted automated daily incremental backups (snapshots) of a Linux server or desktop. I have been using this method on various servers for several months and it has proved to be a reliable, secure, cheap, and robust method to create automated backups.
I [...]]]></description>
			<content:encoded><![CDATA[<p>This guide shows how to use <a href="http://aws.amazon.com/s3/">Amazon S3</a> with <a href="http://duplicity.nongnu.org/">duplicity</a> to make secure GPG encrypted automated daily incremental backups (snapshots) of a Linux server or desktop. I have been using this method on various servers for several months and it has proved to be a reliable, secure, cheap, and robust method to create automated backups.</p>
<p>I have used this method on <a href="http://fedoraproject.org/">Fedora</a>, <a href="http://us.fixstars.com/products/ydl/">YDL</a>, and <a href="http://www.centos.org/">CentOS</a> but the instructions should equally apply to other Linux distributions including <a href="http://www.debian.org/">Debian</a> and <a href="http://www.ubuntu.com/">Ubuntu</a>. It will even work on OS X using the <a href="http://www.macports.org/">MacPorts</a> version of duplicity.</p>
<h3 id="toc-aims-of-this-guide">Aims of this guide</h3>
<p>This guide explains how to create a simple wrapper script for duplicity that allows you to automatically create GPG encrypted incremental backups that are saved to an Amazon S3 bucket. The script is designed to be executed as a daily cron job so that incremental snapshot backups are created each day. The script creates a full backup set on the 1st day of each month (or when an appropriate full backup cannot be found) and then creates incremental backups on subsequent days. </p>
<p>This guide provides a walk-through of how to create the GPG encryption key, and provides full scripts and example usage for both backup and restore. You could easily adapt the backup script so that it makes full backups each week, or otherwise adjust it to suit your individual needs.</p>
<p>This guide is written with the general Linux user in mind: you do need some understanding of basic linux concepts such as cron, permissions, and directory structures.</p>
<p><span id="more-54"></span></p>
<h3 id="toc-what-is-duplicity">What is duplicity?</h3>
<p>From the duplicity home page:</p>
<blockquote><p>Duplicity backs [up] directories by producing encrypted tar-format volumes and uploading them to a remote or local file server. Because duplicity uses librsync, the incremental archives are space efficient and only record the parts of files that have changed since the last backup. Because duplicity uses GnuPG to encrypt and/or sign these archives, they will be safe from spying and/or modification by the server.</p></blockquote>
<p>I think that says it all much more concisely than I could manage.</p>
<p>One thing to note is that in my experience, and on certain machines, duplicity can cause a lot of overhead and take a long time to complete. Thus duplicity is not always a viable option when backing up huge amounts of data. That said, for backing up the critical data from a standard web server it can be a great solution. Remember, that if you're backing up databases then you need to dump them into SQL files first. For MySQL databases I recommend <a href="http://sourceforge.net/projects/automysqlbackup/">automysqlbackup</a> for this. As always, YMMV.</p>
<h3 id="toc-before-we-start">Before we start</h3>
<p>You need to install duplicity (version &gt;= 0.4.3 for S3 support). This how-to doesn't cover that aspect, but suffice to say that duplicity is available as a package for most major distros so crack open your package manager (be it yum, apt, synaptics or whatever) and install duplicity along with all it's dependencies. </p>
<p>You also need GnuGP and librsync but they should both be automatically installed as dependencies of duplicity.</p>
<h3 id="toc-step-1-generate-a-new-gpg-key">Step 1 - Generate a new GPG key</h3>
<p>If you already have a GPG key that you want to use then skip this bit - you'll just need to know what your key is which you can get through "gpg --list-keys" - it is the bit after the / in the "pub" line. Otherwise, read on...</p>
<p>I am going to presume that you'll be running your backup jobs as root, so open a terminal and become root. If you're going to run them as a different user then become that user instead but ensure that the user you have chosen has sufficient permissions to backup the data you require.</p>
<p>Now run "gpg --gen-key" to generate your key and follow the prompts:</p>
<pre><code># gpg --gen-key
gpg (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) DSA and Elgamal (default)
   (2) DSA (sign only)
   (5) RSA (sign only)
Your selection?
</code></pre>
<p>Accept the default (Enter) or press 1 for DSA and Elgamal.</p>
<pre><code>DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) </code></pre>
<p>Again, the default (2048) is fine. Just hit Enter.</p>
<pre><code>Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      &lt;n&gt;  = key expires in n days
      &lt;n&gt;w = key expires in n weeks
      &lt;n&gt;m = key expires in n months
      &lt;n&gt;y = key expires in n years
Key is valid for? (0) </code></pre>
<p>I don't want my key to expire, so I just hit Enter again to accept the default. Do whatever you want.</p>
<pre><code>Key does not expire at all
Is this correct? (y/N) </code></pre>
<p>Sure is. Hit y and then Enter.</p>
<pre><code>You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) &lt;heinrichh@duesseldorf.de&gt;"

Real name: Duplicity Backup
Email address: duplicity@mydomain.com
Comment: Key for duplicity
You selected this USER-ID:
    "Duplicity Backup (Key for duplicity) &lt;duplicity@mydomain.com&gt;"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?</code></pre>
<p>Enter the requested details and then press O for Okay.</p>
<pre><code>You need a Passphrase to protect your secret key.

Enter Passphrase:</code></pre>
<p>Enter a passphrase here. It should be something long and complex. Anything will do, but make sure you remember it because you'll need it later. When finished press Enter and then re-enter your passphrase when prompted and then press Enter again.</p>
<p>At this stage you may have to help generate some entropy by doing some other task - I find that running "updatedb" in another shell is pretty good, or just randomly tapping the keyboard can do the trick too.</p>
<p>Once it has finished you should get a message like this:</p>
<pre><code>gpg: key BE9274BD marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   1024D/BE9274BD 2008-11-30
      Key fingerprint = 2FB4 A20E 57BA 80BA 9576  3ABD F79F D430 BE92 74BD
uid                  Duplicity Backup (Key for duplicity) &lt;duplicity@mydomain.com&gt;
sub   2048g/F8F35AD8 2008-11-30</code></pre>
<p>Make a note of the key (BE9274BD in this case) as you'll need that later too.</p>
<p><strong><em>Important: Remember to backup your GPG key pair somewhere safe and off the current machine. Without this key pair your backups are totally useless to you, so if you lose it and need to restore a backup then you're up a creak without a paddle. <a href="http://www.debuntu.org/how-to-import-export-gpg-key-pair">This article</a> shows the proper way to export (and import) your GPG key pair.</em></strong></p>
<h3 id="toc-step-2-the-backup-wrapper-script">Step 2 - The backup wrapper script</h3>
<p>This bash wrapper script does a full backup on the 1st day of each month followed by incremental backups on subsequent days. It will also delete old backup sets after X months have passed and it also emails a log report each day giving some valuable statistics about your backup and reporting any errors.</p>
<p>You will need to have the following information handy to edit this backup script for your needs:</p>
<ul>
<li>Your Amazon S3 Access Key ID</li>
<li>Your Amazon S3 Secret Access Key</li>
<li>Your GPG key</li>
<li>Your GPG key passphrase</li>
<li>A list of directories you want to back up</li>
<li>An email address to send the logs to</li>
<li>A unique name for an Amazon S3 bucket (the bucket will be created if it doesn't yet exist)</li>
</ul>
<p>The script is as follows, you need to change the bits in bold at least but pay attention to all the variables as you may want to tweak them to suit your needs.</p>
<p>Note that includes/excludes work on a 'fist match' basis. So if you want to exclude something in a directory, you need to exclude the file/subdirectory before including the directory. For more info see the duplicity man pages.</p>
<pre><code>#!/bin/bash

# Set up some variables for logging
LOGFILE="/var/log/backup.log"
DAILYLOGFILE="/var/log/backup.daily.log"
HOST=`hostname`
DATE=`date +%Y-%m-%d`
MAILADDR="<strong>sysadmin@mydomain.com</strong>"

# Clear the old daily log file
cat /dev/null &gt; ${DAILYLOGFILE}

# Trace function for logging, don't change this
trace () {
        stamp=`date +%Y-%m-%d_%H:%M:%S`
        echo "$stamp: $*" &gt;&gt; ${DAILYLOGFILE}
}

# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="<strong>YOUR_ACCESS_KEY_ID</strong>"
export AWS_SECRET_ACCESS_KEY="<strong>YOUR_SECRET_ACCESS_KEY</strong>"
export PASSPHRASE="<strong>YOUR_GPG_PASSPHRASE</strong>"

# Your GPG key
GPG_KEY=<strong>YOUR_GPG_KEY</strong>

# How long to keep backups for
OLDER_THAN="3M"

# The source of your backup
SOURCE=/

# The destination
# Note that the bucket need not exist
# but does need to be unique amongst all
# Amazon S3 users. So, choose wisely.
DEST="s3+http://<strong>your_s3_bucket_name</strong>"

FULL=
if [ $(date +%d) -eq 1 ]; then
        FULL=full
fi;

trace "Backup for local filesystem started"

trace "... removing old backups"

duplicity remove-older-than ${OLDER_THAN} ${DEST} &gt;&gt; ${DAILYLOGFILE} 2&gt;&amp;1

trace "... backing up filesystem"

duplicity \
    ${FULL} \
    --encrypt-key=${GPG_KEY} \
    --sign-key=${GPG_KEY} \
    --volsize=250 \
<strong>    --include=/vhosts \
    --include=/etc \
    --include=/home \
    --include=/root \
    --exclude=/** \</strong>
    ${SOURCE} ${DEST} &gt;&gt; ${DAILYLOGFILE} 2&gt;&amp;1

trace "Backup for local filesystem complete"
trace "------------------------------------"

# Send the daily log file by email
cat "$DAILYLOGFILE" | mail -s "Duplicity Backup Log for $HOST - $DATE" $MAILADDR

# Append the daily log file to the main log file
cat "$DAILYLOGFILE" &gt;&gt; $LOGFILE

# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=
</code></pre>
<p>Save the script somewhere and give it an appropriate name. I saved it a /usr/bin/duplicity-backup and make sure to chmod the script to 700 - it contains some sensitive information so we don't want none privileged users to have read access to it. Run the script as a test then set it up as a daily cron job to run at an appropriate time of night when the server isn't doing much else.</p>
<h3 id="toc-step-3-the-restore-wrapper-script">Step 3 - The restore wrapper script</h3>
<p>Clearly we need a way to restore from a backup, so use the following script to do just that:</p>
<pre><code>#!/bin/bash
# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="<strong>YOUR_ACCESS_KEY_ID</strong>"
export AWS_SECRET_ACCESS_KEY="<strong>YOUR_SECRET_ACCESS_KEY</strong>"
export PASSPHRASE="<strong>YOUR_GPG_PASSPHRASE</strong>"

# Your GPG key
GPG_KEY=<strong>YOUR_GPG_KEY</strong>

# The destination
DEST="s3+http://<strong>your_s3_bucket_name</strong>"

if [ $# -lt 3 ]; then echo "Usage $0 &lt;date&gt; &lt;file&gt; &lt;restore-to&gt;"; exit; fi

duplicity \
    --encrypt-key=${GPG_KEY} \
    --sign-key=${GPG_KEY} \
    --file-to-restore $2 \
    --restore-time $1 \
    ${DEST} $3

# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE= </code></pre>
<p>Again, save this file as something sensible and chmod it to 700 to prevent prying eyes. I saved it as /usr/bin/duplicity-restore but feel free to put it wherever you like.</p>
<p>To do a restore simply invoke the script as follows:</p>
<pre><code>duplicity-restore &lt;date&gt; &lt;file&gt; &lt;restore-to&gt;</code></pre>
<p>Some notes on usage: Paths are relative not absolute. So /home/username would be backed up as home/username. You can restore whole directories but the destination needs to exist first. For example, to restore /home/username from November 20 2008 to a local directory 'restore', doing the <strong>following would not work</strong> because ./home does not exist:</p>
<pre><code>cd ~
mkdir restore
cd restore
duplicity-restore "2008-11-20" home/username home/username</code></pre>
<p>However, the <strong>following would work</strong> and would restore the directory to ./username:</p>
<pre><code>duplicity-restore "2008-11-20" home/username username</code></pre>
<p>That's all there is to it. As mentioned I've been using this method for several months to back up a variety of servers and it works very nicely. I hope it works just as well for you too!</p>
<h3 id="toc-credits">Credits</h3>
<p>This solution is the combination of a couple of tips and tricks I found while trawling the web, notably from <a href="http://www.randys.org/2007/11/16/how-to-automated-backups-to-amazon-s-s3-with-duplicity/">this howto at randys.org</a> and <a href="http://www.linode.com/forums/viewtopic.php?p=14875#14875">this post over at the linode.com forums</a>. Credit and thanks goes to the original authors - I have merely hacked their ideas together and added a few touches of my own.</p>
<p>If you find this useful or have any comments or questions then please respond below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cenolan.com/2008/12/how-to-incremental-daily-backups-amazon-s3-duplicity/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Simple Linux to Amazon S3 backup script</title>
		<link>http://www.cenolan.com/2008/05/simple-linux-to-amazon-s3-backup-script/</link>
		<comments>http://www.cenolan.com/2008/05/simple-linux-to-amazon-s3-backup-script/#comments</comments>
		<pubDate>Mon, 05 May 2008 13:05:53 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://www.cenolan.com/?p=10</guid>
		<description><![CDATA[There are many tools available to help backup Linux systems to Amazon S3 but finding the right one to use can be difficult. Jeremy Zawodny made a good list of various S3 backup tools which is very helpful, if a little outdated. I experimented with a few tools, including some of the standard scripts published [...]]]></description>
			<content:encoded><![CDATA[<p>There are many tools available to help backup Linux systems to Amazon S3 but finding the right one to use can be difficult. Jeremy Zawodny made a <a title="S3 backup Tools" href="http://jeremy.zawodny.com/blog/archives/007641.html">good list of various S3 backup tools</a> which is very helpful, if a little outdated. I experimented with a few tools, including some of the standard scripts published by Amazon but I found each had their own shortcomings.</p>
<p>One tool that is very simple to use is <a href="http://s3tools.logix.cz/s3cmd">s3cmd</a> which is a linux command line tool to upload, retrieve, and manage data in Amazon S3. The tool is written in python so should install and run on pretty much any modern linux distro and I have found it works very nicely and seems to be an ideal tool to use if you want to write a basic backup script.</p>
<p><span id="more-10"></span></p>
<p>Once installed you just run "s3cmd --configure" to configure the script with your Amazon S3 access keys. You can then use s3cmd from the command line to manage your S3 buckets and their contents. Full details of the various options can be obtained through running "s3cmd --help".</p>
<p>I have used s3cmd to create automated daily rotated backups of a single directory (e.g. /home) using a simple bash script which I adapted from the <a href="http://sourceforge.net/projects/automysqlbackup/">automysqlbackup</a> script. The script I have used is shown below, and provides rotated backups of the previous 7 days, each day individually archived in a single tar.gz file. This is a fairly limited solution as it only provides a backup of a single directory, does not do incremental backups, and it will break if your tar.gz file exceeds the S3 individual file storage limit of ~6GB. However, if you just need a simple solution to maintain daily backups of a single folder then its a nice tidy option. It will also email you the results, and can optionally include jobs to run pre- and post- backup.</p>
<pre><code>#!/bin/bash
#
# Backup Script
#
#=====================================================================
#=====================================================================
# Set the following variables to your system needs
#=====================================================================

# Directory to save daily tar.gz backup files to e.g /backups
BACKUPDIR="/backups"

# Directory to backup
BACKUPSRCDIR="/home"

# Maximum size of backup files in MB (larger files will be split into separate archives)
# Note: not implemented yet
MAXTARSIZE="1000"

# S3 Settings
# The name of the S3 bucket to upload to e.g. "my_s3_bucket"
S3BUCKET="my_s3_bucket"

# Mail setup
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and tar.gz files as attachments
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
MAILCONTENT="log"

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
MAXATTSIZE="4000"

# Email Address to send mail to? (user@domain.com)
MAILADDR="user@domain.com"

# Command to run before backups (uncomment to use)
#PREBACKUP="/etc/backup-pre"

# Command run after backups (uncomment to use)
#POSTBACKUP="/etc/backup-post"

#=====================================================================
#=====================================================================
#=====================================================================
#
# Should not need to be modified from here down!!
#
#=====================================================================
#=====================================================================
#=====================================================================
PATH=/usr/local/bin:/usr/bin:/bin:
DATE=`date +%Y-%m-%d_%Hh%Mm`                            # Datestamp e.g 2002-09-21
DOW=`date +%A`                                          # Day of the week e.g. Monday
DNOW=`date +%u`                                         # Day number of the week 1 to 7 where 1 represents Monday
DOM=`date +%d`                                          # Date of the Month e.g. 27
M=`date +%B`                                            # Month e.g January
W=`date +%V`                                            # Week Number e.g 37
VER=0.1                                                 # Version Number
HOST=`hostname`                                         # Hostname for LOG information
LOGFILE=$BACKUPDIR/$HOST-`date +%N`.log                 # Logfile Name
LOGERR=$BACKUPDIR/ERRORS_$HOST-`date +%N`.log           # Error log Name
BACKUPFILES=""

# Create required directories
if [ ! -e "$BACKUPDIR" ]                # Check Backup Directory exists.
then
mkdir -p "$BACKUPDIR"
fi

# IO redirection for logging.
touch $LOGFILE
exec 6&gt;&amp;1           # Link file descriptor #6 with stdout.
# Saves stdout.
exec &gt; $LOGFILE     # stdout replaced with file $LOGFILE.
touch $LOGERR
exec 7&gt;&amp;2           # Link file descriptor #7 with stderr.
# Saves stderr.
exec 2&gt; $LOGERR     # stderr replaced with file $LOGERR.

# Functions

# Backup function: removes last weeks archive from S3, creates new tar.gz and sends to S3
SUFFIX=""
dobackup () {
s3cmd ls s3://"$S3BUCKET" | grep s3 | sed "s/.*s3:\/\/$S3BUCKET\//s3:\/\/$S3BUCKET\//" | grep "$DOW" | xargs s3cmd del
tar cfz "$1" "$2"
echo
echo Backup Information for "$1"
gzip -l "$1"
echo
s3cmd put "$1" s3://"$S3BUCKET"
return 0
}

# Run command before we begin
if [ "$PREBACKUP" ]
then
echo ======================================================================
echo "Prebackup command output."
echo
eval $PREBACKUP
echo
echo ======================================================================
echo
fi

echo ======================================================================
echo BackupScript VER $VER
echo http://www.cenolan.com/
echo
echo Backup of Server - $HOST
echo ======================================================================

echo Backup Start Time: `date`
echo ======================================================================
# Daily Backup
echo Daily Backup of Directory \( $BACKUPSRCDIR \)
echo
echo Rotating last weeks Backup...
eval rm -fv "$BACKUPDIR/*.$DOW.tar.gz"
echo
dobackup "$BACKUPDIR/$DATE.$DOW.tar.gz" "$BACKUPSRCDIR"
BACKUPFILES="$BACKUPFILES $BACKUPDIR/$DATE.$DOW.tar.gz"
echo
echo ----------------------------------------------------------------------
echo Backup End Time: `date`
echo ======================================================================
echo Total disk space used for backup storage..
echo Size - Location
echo `du -hs "$BACKUPDIR"`
echo
echo ======================================================================
echo ======================================================================

# Run command when we're done
if [ "$POSTBACKUP" ]
then
echo ======================================================================
echo "Postbackup command output."
echo
eval $POSTBACKUP
echo
echo ======================================================================
fi

#Clean up IO redirection
exec 1&gt;&amp;6 6&gt;&amp;-      # Restore stdout and close file descriptor #6.
exec 1&gt;&amp;7 7&gt;&amp;-      # Restore stdout and close file descriptor #7.

if [ "$MAILCONTENT" = "files" ]
then
if [ -s "$LOGERR" ]
then
# Include error log if is larger than zero.
BACKUPFILES="$BACKUPFILES $LOGERR"
ERRORNOTE="WARNING: Error Reported - "
fi
#Get backup size
ATTSIZE=`du -c $BACKUPFILES | grep "[[:digit:][:space:]]total$" |sed s/\s*total//`
if [ $MAXATTSIZE -ge $ATTSIZE ]
then
BACKUPFILES=`echo "$BACKUPFILES" | sed -e "s# # -a #g"` #enable multiple attachments
mutt -s "$ERRORNOTE MySQL Backup Log and SQL Files for $HOST - $DATE" $BACKUPFILES $MAILADDR &lt; $LOGFILE       #send via mutt
else
cat "$LOGFILE" | mail -s "WARNING! - Backup exceeds set maximum attachment size on $HOST - $DATE" $MAILADDR
fi
elif [ "$MAILCONTENT" = "log" ]
then
cat "$LOGFILE" | mail -s "Backup Log for $HOST - $DATE" $MAILADDR
if [ -s "$LOGERR" ]
then
cat "$LOGERR" | mail -s "ERRORS REPORTED: MySQL Backup error Log for $HOST - $DATE" $MAILADDR
fi
elif [ "$MAILCONTENT" = "quiet" ]
then
if [ -s "$LOGERR" ]
then
cat "$LOGERR" | mail -s "ERRORS REPORTED: Backup error Log for $HOST - $DATE" $MAILADDR
cat "$LOGFILE" | mail -s "Backup Log for $HOST - $DATE" $MAILADDR
fi
else
if [ -s "$LOGERR" ]
then
cat "$LOGFILE"
echo
echo "###### WARNING ######"
echo "Errors reported during Backup execution.. Backup failed"
echo "Error log below.."
cat "$LOGERR"
else
cat "$LOGFILE"
fi
fi

if [ -s "$LOGERR" ]
then
STATUS=1
else
STATUS=0
fi

# Clean up Logfile
eval rm -f "$LOGFILE"
eval rm -f "$LOGERR"

exit $STATUS</pre>
<p></code><br />
I have posted this largely for my own information but maybe somebody else will find this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cenolan.com/2008/05/simple-linux-to-amazon-s3-backup-script/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
