nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

ssh backup particular mysql table / database

This is a discussion on ssh backup particular mysql table / database within the Databases servers forums, part of the Mastering Servers category; I have ssh access no problem what I do not understand is how to command should I command all those ...


Go Back   nixCraft Linux Forum > Mastering Servers > Databases servers

Register FAQ Members List Calendar Mark Forums Read
  #11 (permalink)  
Old 10-25-2007, 01:47 PM
Junior Member
User
 
Join Date: Oct 2007
My distro: Debian
Posts: 6
Rep Power: 0
brothers is on a distinguished road
Default

I have ssh access no problem what I do not understand is how to command should I command all those codes you provided?
or just this part

Code:
#!/bin/bash
DBNAME="phpbb"
DBPASS="myPassWord"
DBUSER="admin"
DBHOST="localhost"
BACKUP="out.sql"
Reply With Quote
Sponsored Links
  #12 (permalink)  
Old 10-25-2007, 05:06 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 964
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
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
how to do MYSQL online backup of huge database manish_2479 Databases servers 4 07-12-2008 12:36 PM
need to convert text files into mysql database zafar466 Databases servers 2 07-12-2008 12:31 PM
MySql FTP server backup script zafar466 Shell scripting 3 09-25-2007 05:43 PM
MySQL Backup Script krisa Shell scripting 1 02-02-2007 11:57 PM
How do I backup MySQL Databases? chiku All about FreeBSD/OpenBSD/NetBSD 2 08-19-2006 07:15 PM


All times are GMT +5.5. The time now is 11:10 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36