D’oh – realized I’d not sent this to the list but just to the OP.

How many databases (or more appropriately how many distinct items) are output 
by the command:

databases=`$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | egrep 
-iv "(Database|information_schema)"

Your for loop is telling it to run the backup for each database produced by the 
above command.  If you have 4-5 then that is the problem.   You probably want 
to put the “done” FROM the end of your script BEFORE that line so it does the 
dump of each database but then only does the backup after they’ve all been 
dumped.

Alternatively you could add logic to do the backup of each dump individually.





From: veritas-bu-boun...@mailman.eng.auburn.edu 
[mailto:veritas-bu-boun...@mailman.eng.auburn.edu] On Behalf Of Anurag Sharma
Sent: Tuesday, May 20, 2014 3:19 PM
To: mia...@gmail.com
Cc: veritas-bu; veritas-bu2
Subject: Re: [Veritas-bu] AUTOMATE MYSQL DUMP BACKUP

All,

Thank you for your help.

Finally I got it working by adding bpbackup command in the end.

Now the problem I am facing is Üser Backup is running 4 to 5 times instead of 
just once. What could be the reason for that ??

Here's  the script I am using .

----------------------------------------------------------------------------------------------------------------------------------------

#!/bin/bash

#The below command will delete the older backup
rm -r /mysql_backup/201*

TIMESTAMP=$(date +"%Y%m%d")
BACKUP_DIR="/mysql_backup/$TIMESTAMP"
MYSQL_USER="mysqlbak"
MYSQL_PASSWORD="Cricket1"
MYSQL=/usr/bin/mysql
# MYSQLDUMP=/usr/bin/mysqldump
MYSQLDUMP=/usr/mysql/5.1/bin/mysqldump
mkdir -p $BACKUP_DIR
databases=`$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | egrep 
-iv "(Database|information_schema)"`
for db in $databases; do
# echo $db
mkdir -p $BACKUP_DIR/$db
BACKUP_DIRR="/mysql_backup/$TIMESTAMP/$db"
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | 
gzip > "$BACKUP_DIRR/$db.sql.gz"

#The below command will start NetBackup Tape backups
/usr/openv/netbackup/bin/./bpbackup -w -p SOPMYSQL02 -s sopmysql02-backup 
/mysql_backup/

done
------------------------------------------------------------------------------------------------------------------------

________________________________
CC: 
veritas-bu@mailman.eng.auburn.edu<mailto:veritas-bu@mailman.eng.auburn.edu>; 
veritas-bu-boun...@mailman.eng.auburn.edu<mailto:veritas-bu-boun...@mailman.eng.auburn.edu>
From: mia...@gmail.com<mailto:mia...@gmail.com>
Subject: Re: [Veritas-bu] AUTOMATE MYSQL DUMP BACKUP
Date: Tue, 20 May 2014 07:15:24 +0200
To: sharma.anu...@hotmail.com<mailto:sharma.anu...@hotmail.com>
Hi Anurag

Yes you would to use bpstart_notify and bpend_notify for this

bpstart_notify to call the backup.sh and bpend_notify to delete the dump after 
successfull backup

Regards
Michael

Sendt fra min iPad

Den 19/05/2014 kl. 21.57 skrev Anurag Sharma 
<sharma.anu...@hotmail.com<mailto:sharma.anu...@hotmail.com>>:
Hi All,

Here's my situation.

MASTER/MEDIA : Solaris 10

Client : Linux/Solaris


There is a backup script created by mysql admin lets call it backup.sh  which 
can do on demand  mysql dump on a directory

/mysql_backup/yyyymmdd. It mean every time you run the script it will create a 
folder with that date.



I have been told to backup these dump files as standard backup.

I need following accomplished.

1. Need to call backup.sh to perform mysql dump and crate dump in 
/mysql_backup/yyyyymmdd
2. Run netbackup backup to backup the dump.
3. Once the netbackup backup is successful delete the dump from disk.


What would be the best way to do it via netbackup ? Do I have to use bpstart 
and bpend scripts on each client ?


Please guide.

Anurag Sharma


_______________________________________________
Veritas-bu maillist  -  
Veritas-bu@mailman.eng.auburn.edu<mailto:Veritas-bu@mailman.eng.auburn.edu>
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

Athena®, Created for the Cause™

Making a Difference in the Fight Against Breast Cancer

____________________________________________________

CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential 
information and is for the sole use of the intended recipient(s). If you are 
not the intended recipient, any disclosure, copying, distribution, or use of 
the contents of this information is prohibited and may be unlawful. If you have 
received this electronic transmission in error, please reply immediately to the 
sender that you have received the message in error, and delete it. Thank you.
_______________________________________________
Veritas-bu maillist  -  Veritas-bu@mailman.eng.auburn.edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu

Reply via email to