Archive forJuly, 2008

Livehelper




Comments off

/home and MySQL backup script

#!/bin/sh
# System + MySQL backup script
# ———————————————————————

### System Setup ###
DIRS=”/etc /home”
DAY=$(date +”%a”)
BACKUP=/dir.backup
EMAILID=yabba@dabba.com

### MySQL Setup ###
MUSER=”username”
MPASS=”password”
MHOST=”localhost”

### FTP server Setup ###
FTPU=”FTPusername”
FTPP=”FTPpassword”
FTPS=”IP.IP.IP.IP”

# Make that them there directory.
if [ ! -d $BACKUP ] ; then
mkdir $BACKUP
fi

### Start MySQL Backup ###
FILE=$BACKUP/drj_all_db.sql.$DAY.gz
mysqldump -u $MUSER -h $MHOST -p$MPASS –all-databases | gzip -9 > $FILE

### Dump backup using FTP ###
lftp -u “$FTPU”,”$FTPP” $FTPS< lcd $BACKUP
put $FILE
quit
EOF
# Comment this out. It will overwrite $? when run and not allow checking
# on the next if statement.
#echo "$?"
### Find out if ftp backup failed or not ###
T=/tmp/backup.fail
if [ "$?" != "0" ]; then
echo "Date: $(date)">$T
echo “Hostname: $(hostname)” >>$T
echo “Remote backup failed! Please investigate! Thank you!” >>$T
mail -s “Backup Failed: Ugg ” “$EMAILID” <$T
rm -f $T
fi

Comments off

Useful EXIM Commands

Here are some useful exim commands. They’re useful if you have an overloaded queue and need to clear it out, or find out why the messagse are being piled up.

exim -M id #Try to send the message with id id

exim -qf #Tell exim to process the entire queue again
exim -qff #same as qf, but it will flush the frozen messages

exim -Mvl id #view the message log for message id
exim -Mvh id #view message id’s headers
exim -Mvb id #view message id’s body
exim -Mrm id #remove message id from the queue
exim -Mg id #fail and send a bounce to the sender
exim -bp | exiqsumm #Print summary of the messages in the queue
exiwhat #show what exim is doing right now
exim -bpc #show number of messages in the queue
exim -bp #print list of messages in the queue

The manual way to remove the entire queue is as follows

cd /var/spool
mv exim exim.old
mkdir -p exim/input
mkdir -p exim/msglog
mkdir -p exim/db
chown -R mail:mail exim

Then restart exim.

Comments off