Welcome! » Log In » Create A New Profile

AUTOMATE MYSQL DUMP BACKUP

Posted by Anonymous 
AUTOMATE MYSQL DUMP BACKUP
May 20, 2014 01:56PM
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.

[b]From:[/b] veritas-bu-bounces < at > mailman.eng.auburn.edu [mailto] [b]On Behalf Of [/b]Anurag Sharma
[b]Sent:[/b] Tuesday, May 20, 2014 3:19 PM
[b]To:[/b] mian71 < at > gmail.com
[b]Cc:[/b] veritas-bu; veritas-bu2
[b]Subject:[/b] 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 [b]Üser Backup [/b]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 < at > mailman.eng.auburn.edu ([email]veritas-bu < at > mailman.eng.auburn.edu[/email]); veritas-bu-bounces < at > mailman.eng.auburn.edu ([email]veritas-bu-bounces < at > mailman.eng.auburn.edu[/email])
From: mian71 < at > gmail.com ([email]mian71 < at > gmail.com[/email])
Subject: Re: [Veritas-bu] AUTOMATE MYSQL DUMP BACKUP
Date: Tue, 20 May 2014 07:15:24 +0200
To: sharma.anurag < at > hotmail.com ([email]sharma.anurag < at > hotmail.com[/email])
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.anurag < at > hotmail.com ([email]sharma.anurag < at > hotmail.com[/email])>:
[quote]
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 < at > mailman.eng.auburn.edu ([email]Veritas-bu < at > mailman.eng.auburn.edu[/email])
[url=http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu]http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu[/url]
[/quote]

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.
Sorry, only registered users may post in this forum.

Click here to login