Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I wrote this backup script. I run rsync, tar and a dump of mysql. I'd like to add some features like email alert or some kind of statistic.

Here is the script:

#!/bin/sh

DATE=`date +%D-%T`
ORIGIN=/home/share/
DEST=/media/BACKUP/mercurio/
LOGFILE=log.txt
echo "=====Starting backup on $DATE =====" >> $LOGFILE
echo "==Start rsync" >> $LOGFILE 
rsync -arHu --delete --stats $ORIGIN $DEST/share >> $LOGFILE
wait
if [ $? -eq 0 ]
then
        echo "==rsync ok"  >> $LOGFILE
else
        echo "==rsync ko"   >> $LOGFILE
fi

echo "==Sart TAR" >> $LOGFILE
tar -czf $DEST`date +%y%m%d-%T`.tar.gz $ORIGIN
wait
if [ $? -eq 0 ]
then
        echo "==tar ok" >> $LOGFILE
else
        echo "==tar ko" >> $LOGFILE
fi
echo "==Start DUMP" >> $LOGFILE
mysqldump -u root -ptoor --all-databases > ${DEST}databases/`date +%Y%m%d-%k:%M`.sql
wait
if [$? -eq 0 ]
then
        echo "==dump ok" >> $LOGFILE
else 
        echo "==dump ko" >> $LOGFILE
fi
echo "=====End Bakcup=====" >> $LOGFILE
share|improve this question
1  
Your question is a bit vague. What kind of email alert? Statistics for what? (And what have you tried for either?) –  Mat Feb 3 '12 at 12:09
    
sorry i don't have a precise idea, i think some guru here can give me some advice like "you need an email alert if backup fails" or "add auto-delete file older than 30days" –  Ignazio Calò Feb 3 '12 at 12:20
1  
So you're asking for general best practices for backups, retention periods, and monitoring? That's a bit broad to say the least. We don't even know what kind of data you're backing up. You also need to take potential legal requirements into consideration. Practical limitations with how much storage you have available... –  Mat Feb 3 '12 at 12:22
    
you're right...this is a too generic question :( The files aren't vital for my business...i copy on this server only the file that i want to share with my colleagues. Server is configured as lamp for a simple wikimedia installation so i want to backup also mysql. –  Ignazio Calò Feb 3 '12 at 12:31
    
You should also redirect stderr to you log files, like 2>>. >> is like 1>> and redirects stdout only. Also use --log-error=filename.log for mysqldump. –  Teresa e Junior Feb 3 '12 at 14:21
show 3 more comments

closed as not a real question by Mat, enzotib, Chris Down, sr_, Gilles Feb 3 '12 at 23:55

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.