It is currently Tue Mar 20, 2018 12:08 am

mysql database backup: 7 days backup & mail confirmation

All times are UTC - 6 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Sep 11, 2007 11:43 am   

Joined: Tue Sep 11, 2007 11:33 am
Posts: 1
i want a script which should backup the mysql database automatically everyday
also should keep only last 7 days back up & a confirmation mail that database backup went fine also date & time of the backup .

i have made a script which takes backup everyday ...however require some help to modify the below script and keep it only for last 7 days script & a confirmation mail

Below is the script which i have made...would appreciate ..if anybody can help me

dt=`date +%d`"-"`date +%m`"-"`date +%y`

cd /home/fic_user/jatin.backup
/usr/bin/mysqldump -u 'username' --p 'password' fic_ashokadb > $BKPFILE1

 PostPosted: Thu Oct 11, 2007 7:40 am   
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 265
Location: London - UK

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`


cd /home/fic_user/jatin.backup
/usr/bin/mysqldump -u 'username' --p 'password' fic_ashokadb > $BKPFILE1

# check if an old backup file exists
# if so then delete it

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: Bing [Bot] and 29 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group