All pastes #995679 Raw Edit

Untitled

public text v1 · immutable
#995679 ·published 2008-04-24 12:04 UTC
rendered paste body
#
# Backup skripta
#

echo "Stage 1: Backup started !"
datum=`date +%Y-%m-%d--_%j_`
cd /backup/

/bin/nice -n 18 tar -zcf bin-$datum.tgz /bin
/bin/nice -n 18 tar -zcf etc-$datum.tgz /etc
/bin/nice -n 18 tar -zcf root-$datum.tgz /root
/bin/nice -n 18 tar -zcf vpopmail-$datum.tgz /home/vpopmail

sleep 2
/bin/nice -n 18 tar -zcf qmail-$datum.tgz /var/qmail

sleep 2
/bin/nice -n 18 tar -zcf mysql-$datum.tgz /var/lib/mysql

sleep 2
for i in `ls -1 /www/`; do /bin/nice -n 18 tar -zcf www-$i-$datum.tgz /www/$i; done

dir=/backup
fulldate=`date +%Y-%m-%d--_%j_`
today=`python -c 'import time; print time.localtime()[-2]'`
log=/var/log/messages

cd $dir
filelist=`ls -1 | grep tgz`
let "passedays = (( $today-6 ))"

for i in $filelist
do
    filedate=`ls -1 $i |cut -d_ -f2`
    if [ "$filedate" -lt "$passedays" ] ; then
       rm -rf $i
    fi
done

porabaprocent=`df -h | grep hda1 | awk '{print $5}' | cut -d% -f1`

if [ "$porabaprocent" -ge "80" ] ; then
   echo "Poraba prostora na backup hda1 disku je presegla mejo 80% ! Sprosti disk ali zmanjsaj backup dneve." | mail -s "[BS] Disk FULL !!! ALERT !!! Disk FULL [BS]" admin@mydomain.com
fi