View Single Post

  #12 (permalink)  
Old 10-25-2007, 06:06 PM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You only set correct value for following 3 variables

DBNAME="phpbb" -> mysql data base name where all 500 tables exists
DBPASS="myPassWord" -> Password to connect $DBNAME
DBUSER="admin" -> Username to access to $DBNAME

Login to server using ssh

Save script as backup.db.sh
Code:
 #!/bin/bash
DBNAME="brothers"
DBPASS="1234"
DBUSER="me"
DBHOST="localhost"
BACKUP="out.sql"
>$BACKUP
echo ""
echo -n "*** Dumping tables to $BACKUP file : "
TABLES=$(mysql -ss -h $DBHOST -u $DBUSER -p$DBPASS $DBNANE -e'show tables like "phpbb_%";')
for t in $TABLES
do
 echo -n " $t "
 mysqldump -h $DBHOST -u $DBUSER -p $DBPASS $DBNAME --tables "$t" >> $BACKUP
done
echo " *** Done."
Run backup.db.sh as follows
Code:
chmod +x backup.db.sh
./backup.db.sh
Your backup should be dumped to out.sql file.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote