Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple automated backup of apache (your websites)
#25

thanks again dude

 

heres the complete script for those that would like to use a similar one in the future

 



Code:
#!/bin/sh

# from and to directories, and tmp directory
BUPDIR='/backup'
SRCDIR='/usr/local/apache'
TMP='/tmp'

# keep how many?
KEEP=2

# DO NOT CHANGE ANYTHING BELOW
##############################

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/mysql/bin

# current date
DATE=`date +"%h_%d_%Y"`

# filename
FILE="${BUPDIR}/apache_backup_${DATE}.tar.bz2"

# do the backup

tar -jcf $FILE --exclude='*/personal/family/gallery2/g2data/albums/2005/*' $SRCDIR >/dev/null 2>&1


if [ `ls -1 $BUPDIR | wc -l` -gt $KEEP ]; then
  i=1
  for each in `ls -1t $BUPDIR`; do
   if [ $i -gt $KEEP ]; then
       rm -f -- ${BUPDIR}/${each}
   fi
   let "i = i + 1"
  done
fi

echo "Apache backup completed. Enjoy"

## STAGE 2
# Backup mysql

mysqldump -u **** -p***** DATABASENAME >> ${BUPDIR}/forums_export_${DATE}.sql

echo "Forums (MySQL) backup completed. Enjoy"

## STAGE 3
# Mail the admin

cat > ${TMP}/backup.txt << EOF
Hi anyweb,

I'm the backup tool from linux-noob.com and I've got a new backup for you.

The date of the backup is ${DATE}

Apache:
The new file is ${FILE} and has `du -sh $FILE | awk '{print $1}'`

Forums:
The forums backup is now: `du -sh ${BUPDIR}/forums_export_${DATE}.sql | awk '{print $1}'`

Have a nice day,
:)

EOF

cat ${TMP}/backup.txt | mail anyweb@linux-noob.com -s 'New Backup'

rm -f -- ${TMP}/backup.txt




 

works fine now, as you can see below

 

Quote:[root@www cron.weekly]# sh apache.cronApache backup completed. Enjoy

Forums (MySQL) backup completed. Enjoy

You have mail in /var/spool/mail/root
 

and

 



Code:
-rw-r--r--   1 root root 2756189055 Jan  4 15:38 apache_backup_Jan_04_2006.tar.bz2
-rw-r--r--   1 root root   22946133 Jan  4 15:38 forums_export_Jan_04_2006.sql




Reply


Messages In This Thread
simple automated backup of apache (your websites) - by Guest - 2004-12-29, 05:52 PM
simple automated backup of apache (your websites) - by anyweb - 2006-01-04, 01:07 PM

Forum Jump:


Users browsing this thread: