MySQL DBA - Tips and Techniques Magazine

13 Nov 2014

Using mysqldump examples

backup_dbs_anyprov.sh

#!/bin/sh

#script to take consistent backup of ANYPROV database

date=`/bin/date +"%d-%m-%y-%H"`

umask 066

( /usr/local/bin/mysqldump -uroot –p** --databases ANYPROV --lock-all-tables | gzip) > /var/mysql-backups/anyprov-$date-`hostname -s`.sql.gz 2> /var/mysql-backups/anyprov-$date-`hostname -s`.sql.err.log

 

B. Take a no-data DDL dump of selected tables from a single database :

 

backup_dbs_anyprov_nodata.sh

 

#!/bin/sh

#script to take no-data backup of ANYPROV database selected tables

 

date=`/bin/date +"%d-%m-%y-%H"`

umask 066

( /usr/local/bin/mysqldump -uroot –p*** --no-data ANYPROV PROVSERVICEVW REPORTGEN | gzip) > /var/mysql-backups/anyprovnd-$date-`hostname -s`.sql.gz 2> /var/mysql-backups/anyprovnd-$date-`hostname -s`.sql.err.log

 

 

C. Take a data dump of selected tables from a single database :

 

backup_anyprov_tables.sh

 

#!/bin/sh

#script to take consistent backup of ANYPROV database

 

date=`/bin/date +"%d-%m-%y-%H"`

umask 066

( /usr/local/bin/mysqldump -uroot –p*** ANYPROV SERVICETEMPLATE SERVICEFEATURETEMPLATE RESPONSEDEFINITION | gzip) > /var/mysql-backups/anyprovtables-$date-`hostname -s`.sql.gz 2> /var/mysql-backups/anyprovtables-$date-`hostname -s`.sql.err.log

 

No comments:

Post a comment