Apis Networks

Access Control Panel
Control Panel Login close
Username
Domain
Password
 
Contact Us
create account
Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2010, 03:45 PM
molesquirrel molesquirrel is offline
Apis Networks User
 
Join Date: Mar 2006
Posts: 17
mysql backups w/ per table files

I've been using the cp's mysql backup, which has done fine backing up thus far. However, there doesn't seem to be a way to have it in this fashion:

mysql_backup_20100101.sql.bz2
----contents
table_1.sql
table_2.sql

where-in each of the tables is isolated to a single file, with the resultant compressed file holding all those table files.

If this is not possible with the cp, what would you suggest for backing it up otherwise? would it be possible for you to show me what the mysql backup script is actually producing in terms of the command-line arguments so that I could possible take that, alter it, then put it in as a cronjob?

Last edited by molesquirrel; 02-03-2010 at 03:47 PM. Reason: (hit post prematurely!)
Reply With Quote
  #2  
Old 02-03-2010, 04:16 PM
Matt's Avatar
Matt Matt is offline
Tech Liaison
 
Join Date: Jun 2005
Location: Atlanta, Georgia
Posts: 941
Send a message via AIM to Matt Send a message via MSN to Matt
There isn't a way directly via mysqldump without enumerating over each table definition. Something like this will work. DB refers to the target database to dump.

Code:
DB=mysql
mkdir $DB
TABLES=`echo "show tables" | mysql -N $DB`
for i in $TABLES
    do mysqldump $DB $i > $DB/$i.sql
done
tar -cvzf "$DB-`date '+%Y%m%d'`.tar.gz" $DB/
rm -f $DB/*.sql
rmdir $DB
Reply With Quote
Reply

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

Forum Jump