Thanks, I haven't tried this yet. Iwant to generate one big file, not
one file per table. I guess I can replace the code in the for loop to
just build the mysqldump command. Thanks for the help! 

-----Original Message-----
From: Steve Poirier [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 02, 2004 1:44 PM
To: 'Josh Howe'; [EMAIL PROTECTED]
Subject: RE: mysqldump

Did you try this one? I simplified it for you. You just need to put this
in
a file and chmod +x the file. Then you can execute it from a crontab or
with
the shell.

~~~ Copy/paste after this ~~~

#!/bin/bash

# Modify following variables

# script will dump the tables that contain the following in the name
expression_to_match="z_"

# database name
database="database_name"

# database host
database_host="localhost"

# directory to dump tables (put ending /)
dump_path="/path/to/dump/"

TABLES=`echo "show tables" | mysql -h$database_host $database | grep
$expression_to_match`

for table in $TABLES

do
        echo $table
        mysqldump $database $table >$dump_path$table
done

# end script

~~ end copy/paste ~~

You may need to twea the TABLES= command if you're using a password.
Same
for mysqldump if you want to put more options such as --opt

_____________________________
Steve Poirier
 

> -----Original Message-----
> From: Josh Howe [mailto:[EMAIL PROTECTED] 
> Sent: November 2, 2004 11:47 AM
> To: Spenser; [EMAIL PROTECTED]
> Subject: RE: mysqldump
> 
> 
> Thanks Spenser, but I'd already tried something similar. What 
> I get when I try this is:
> 
> mysqldump: Can't get CREATE TABLE for table `z_*` (Table 
> 'sinu_com.z_*'
> doesn't exist)
> 
> 
> 
> -----Original Message-----
> From: Spenser [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 01, 2004 6:30 PM
> To: Josh Howe
> Subject: Re: mysqldump
> 
> Take a look at this article: 
> http://www.unixreview.com/documents/s=8989/ur0408d/
> 
> There's a section on mysqldump if you prefer using it.  You 
> would do something like the following to backup only certain 
> tables based on their names starting with z_.
> 
> mysqldump -u root -p -x -e db1 z_* > /tmp/backup/db1_table1.sql
> 
> 
> 
> On Mon, 2004-11-01 at 11:30, Josh Howe wrote:
> >  
> > Hi,
> > Can anybody help me with a linux newbie question. I want to use 
> > mysqldump to backup all of the tables in a database that start with
> z_.
> > Can I do this in linux with a single line? Thanks.
> > 
> 
> 
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to