|
Yo,
For backups I strongly recommend using a different date format so it's easy to use bash tools to search for particular dates, you should be able to modify my changes back to the old format if required. Also in my opinion mysqlhotcopy is a better backup system (check mysql site) depending on your version of mysql.
This should do, although there are _many_ improvements I would normally put into one of my own backup scripts.
# combining the date commands into 1 command is tidier and easier to read
today=`date +%Y-%m-%d`
# note the use of '-d' switch to specify which date I want
lastweek=`date -d '7 days ago' +%Y-%m-%d`
BKPFILE1="$HOME/jatin.backup/jatin_dump_${today}.sql"
BKPFILEDELETE="$HOME/jatin.backup/jatin_dump_${lastweek}.sql"
cd /home/fic_user/jatin.backup
/usr/bin/mysqldump -u 'username' --p 'password' fic_ashokadb > $BKPFILE1
# check if an old backup file exists
if [ -e $BKPFILEDELETE ]
then
# if so then delete it
rm $BKPFILEDELETE
fi
|