You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
zip2 "$TAR"<br />
echo "...done." >> "$LOGFILE"<br />
echo "Copying to $SERVER..." >> "$LOGFILE"<br />
scp "$BZIP" "$SERVER:$RDIR" > /dev/null 2>&1<br />
echo "...done." >> "$LOGFILE"<br />
echo -e "Done backing up Linux course:\nSource files, PNG and EPS images.\nRubbish removed." >> "<br />
rm "$BZIP"<br />
}<br />
bupbash()<br />
{<br />
DIR="/nethome/tille/xml/db/"<br />
TAR="<strong>Bash</strong>.tar"<br />
BZIP="$TAR.bz2"<br />
FILES="bash-programming/"<br />
SERVER="rincewind"<br />
RDIR="/var/www/intra/tille/html/training/"<br />
cd "$DIR"<br />
tar cf "$TAR" "$FILES"<br />
echo "Compressing $TAR..." >> "$LOGFILE"<br />
bzip2 "$TAR"<br />
echo "...done." >> "$LOGFILE"<br />
echo "Copying to $SERVER..." >> "$LOGFILE"<br />
scp "$BZIP" "$SERVER:$RDIR" > /dev/null 2>&1<br />
echo "...done." >> "$LOGFILE"<br />
echo -e "Done backing up <strong>Bash</strong> course:\n$FILES\nRubbish removed." >> "$LOGFILE"<br />
rm "$BZIP"<br />
}<br />
DAY=`date +%w`<br />
<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />
if [ "$DAY" -lt "2" ]; then<br />
echo "It is `date +%A`, only backing up <strong>Bash</strong> course." >> "$LOGFILE"<br />
bupbash<br />
else<br />
buplinux<br />
bupbash<br />
fi<br />
echo -e "Remote backup `date` SUCCESS\n----------" >> "$LOGFILE"<br />
This script runs from cron, meaning without user interaction, so we redirect standard error from the scp<br />
command to /dev/null.<br />
It might be argued that all the separate steps can be combined in a command such as<br />
tar c dir_to_backup/ | bzip2 | ssh server "cat > backup.tar.bz2"<br />
However, if you are interested in intermediate results, which might be recovered upon failure of the script, this<br />
is not what you want.<br />
The expression<br />
command &> file<br />
is equivalent to<br />
Chapter 11. Functions 135