(SSH) How to backup/restore just some table?


#1

Hi guys, i know how to backup and restore the entire mysql using ssh in wiki
http://wiki.dreamhost.com/Category:Backup
http://wiki.dreamhost.com/Restore_MySQL

to backup
mysqldump --opt -uusername -ppassword -h yourMySQLHostname dbname > output.sql

to restore
mysql -u dbuser -p -h dbhost.yoursite.com dbname < /path/to/backup.sql

but how to backup/restore just some table in the mysql using ssh??

what is the command to do that??? there is no instruction in wiki


#2

I’m not sure what the exact command is but you may want to try looking at the man pages for mysqldump and mysql. You can do this in shell by typing:

man mysqldump
man mysql

Hope this helps!


#3

Test this first just to be safe.

to backup
mysqldump -uusername -ppassword -h yourMySQLHostname dbname tableA tableB tableC > output.sql

Note the table or tables follows the database name.

to restore
mysql -u dbuser -p -h dbhost.yoursite.com -D dbname < /path/to/backup.sql

The -D option is used to extract the tables data from the backup.sql you made in the backup process.

I have not used this for a long time so please try it out first in a test.


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK! :@

Act on my advice at your own risk!


#4

Thank you, the backup command is working to backup only selected table

mysqldump -uusername -ppassword -h yourMySQLHostname dbname tableA tableB tableC > output.sql

but to restore its wrong, this is the correct command

mysql -u user -p -h host.yoursite.com -D dbname < /path/to/backup.sql

i have try it and success, thank you

maybe someone can add this to wiki, it will very helpfull for others


#5

I do believe that you can add this to the wiki yourself.

[quote]but to restore its wrong, this is the correct command

mysql -u user -p -h host.yoursite.com -D dbname < /path/to/backup.sql[/quote]
Perhaps if you have 5 minutes you can explain, for the benefit of others, what is wrong in the restoration command I gave above?


Norm

Opinions are my own views, not DreamHosts’.
I am NOT a DreamHost employee OK! :@

Act on my advice at your own risk!