Hey Dave, Sounds like you're asking about mysqldump --all-databases, but to answer your scripting question:
$ mysql -B -e 'show databases;' | grep -v -e '^Database$' -e '^information_schema$' | while read db; do mysqldump "$db" > "$db".sql; bzip2 "$db.sql"; done There is a mysqlshow command, but it has the fancy formatting. The -B option gives unix friendly output. And the grep -v removes 2 lines you probably don't care about. On Mon, Jul 7, 2014 at 10:52 AM, Tisdell, Dave <[email protected]> wrote: > Hi all, > > I have several mysql databases that I want to run separate backups of rather > than doing an entire database dump into 1 file. > The idea is that each database backup would go into its own directory at the > end of the backup path i.e. > /dbbackups/database1/db-back1 > /dbbackups/database 2/db-back2 > etc > What I have done so far is use the sql "SHOW DATABASES" command to redirect > to a dblist text file. What I would like the script to do is go through the > file and backup every database in the list. I am already using sed to remove > the word database that gets generated by the show command and any databases > I don't want backed up from the list so that the result is a list of > databases that want backed up. > Periodically databases get added. The idea is that the backup will > automatically add the new databases without my editing the script based > upong the list generated by the "Show Databases" command. > I am getting to a level of complexity in scripting that I have not done > before. I want the same set of commands run on every db in the list. > Thanks. > > Dave > > -- > David Tisdell. Music Teacher > Browns River Middle School > 20 River Road > Jericho, VT 05465 > [email protected] (e-mail) > > This e-mail may contain information protected under the Family Educational > Rights and Privacy Act (FERPA). If this e-mail contains student information > and you are not entitled to access such information under FERPA, please > notify the sender. Federal regulations require that you destroy this e-mail > without reviewing it and you may not forward it to anyone. -- In general, we reserve the right to have a poor memory--the computer, however, is supposed to remember! Poor computer. -- Guy Lewis Steele Jr.
