Mysql Backup Script 2
Need a way to backup all your mysql databases in seperate files without eating up your hard drive, then this is the script you need.
Its a bash shell script that will export all your databases with mysqldump into seperate files named like 'database-date.sql'. It will also delete your old backups so you don't fill up your hard drive.
#!/bin/bash
DBHOST='localhost'
DBUSER='root'
DBPASSWD='password'
LOCALDIR=/path/to/your/backup/directory/
# Using the date function's --date="last week" to delete backups that are 7 days old
OLDSUFFIX=`date --date="last week" +%Y%m%d`
SUFFIX=`date +%Y%m%d`
DBS=`mysql -u$DBUSER -p$DBPASSWD -h$DBHOST -e"show databases"`
su_cmd=""
for DATABASE in $DBS; do
if [ $DATABASE != "Database" ]; then
OLDFILENAME=$OLDSUFFIX-$DATABASE.sql
FILENAME=$SUFFIX-$DATABASE.sql
su_cmd="${su_cmd} rm -f $LOCALDIR$OLDFILENAME;"
mysqldump -u$DBUSER -p$DBPASSWD -h$DBHOST $DATABASE > $LOCALDIR$FILENAME
fi
done
su -c "${su_cmd}"
echo "done";
Trackbacks
Use the following link to trackback from your own site:
http://blog.randomutterings.com/articles/trackback/21
-
Prozac mood disorder. Prozac side effects. Prozac. Prozac withdrawal.
-
Don’t need to say much, everything is in the title of this post . Here is the my database backup script: DIR=”/var/backups/db/” MAIL=”your@mail.address” LOGFILE=$DIR/backupdb.log function backup_db { HOST=”$1...
-
Don’t need to say much, everything is in the title of this post . Here is the my database backup script: DIR=”/var/backups/db/” MAIL=”your@mail.address” LOGFILE=$DIR/backupdb.log function backup_db { HOST=”$1...
-
Celebrity movie archive. Desperados celebrity megalinks. Celebrity pics. Celebrity gossip. Free celebrity.

Don't forget to change the DBUSER, DBPASSWD, and LOCALDIR to something appropriate.
If you need more detailed help, post a comment with any specific questions you have and I'll be happy to assist.