If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Mysql Backup

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-04, 14:58
lalancette lalancette is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Red face Mysql Backup

i have 4 database

DB1
DB2
DB3
DB4

And i need to backup them with mysqldump but not all of them in one file. I need 4 different files.
Reply With Quote
  #2 (permalink)  
Old 04-15-04, 18:24
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
So what is the question? Use mysqldump on each and use a different filename for each of the dumps.
Reply With Quote
  #3 (permalink)  
Old 04-16-04, 14:30
bookmal bookmal is offline
Registered User
 
Join Date: Feb 2004
Posts: 4
Code:
#!/bin/sh

# MySQL hostname
DBHOST='hostname'

# MySQL username
DBUSER='user'

# MySQL password
DBPASSWD='password'
 
# directory to dump backups to
DESTDIR=/path/to/backup

# format todays date
TODAY=`date +%Y-%m-%d`

# create directory for todays backup if needed
if [ ! -e $DESTDIR/$TODAY ]; then
    mkdir $DESTDIR/$TODAY
fi

# get all databases
DBS=`mysql -u$DBUSER -p$DBPASSWD -h$DBHOST -e"show databases"`

for DATABASE in $DBS
do
    if [ $DATABASE != "Database" ]; then
        # let's put date here too in case archives get moved around later on
        FILENAME=$TODAY-$DATABASE.gz
        mysqldump -u$DBUSER -p$DBPASSWD -h$DBHOST $DATABASE | gzip --best > $DESTDIR/$TODAY/$FILENAME
    fi
done

exit 0
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On