Activities

March 2008
M T W T F S S
    May »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Simple MySQL backup scripts

# This scripts will take the backup of given database using a dated naming convention

TODAY=DBname`date +%d-%m-%y`
TODAY=$TODAY.sql
#dest_dir keeping the backu locally
dest_dir=/home/installation/backup/
#arch_dir is the place folder ftp location
arch_dir=/home/installation/ftp/
mysqldump -B <DB> -r $dest_dir$TODAY -u<DBuser>  -p<pwd>

#tar cvf – $dest_dir$TODAY | gzip > $arch_dir$TODAY.tar.gz
# moving to local backup directory
cd $dest_dir
#removing old ftp backup
rm -rf $arch_dir/*
tar czvf $arch_dir$TODAY.tar.gz $TODAY

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>