MySQL Forums
Forum List  »  InnoDB

troubles using mysqldump with innodb tables use this simple script
Posted by: Rafael Avaria
Date: February 01, 2005 09:54AM

#!/bin/sh

USER="user"
PASSWD="pass"
DATABASE="db"
COMMAND="/usr/bin/mysqldump"
DIR="/somo dir/"
FILE="$DIR/backup`date +"%F_%H-%M-%S"`.sql";
GFILE="$FILE.gz"


#here is the magic. this array have the tables in the same order of creation,
# only modify the tables with your scheme and is ready for use.......

declare -a TABLES
TABLES_DB1=(dbClientes dbCicloProducto dbEstadoCicloProducto dbEstados dbPersonas dbTelefonos dbRegiones dbOficinas dbDistribuidores dbUsuarios dbGrupos dbSubGrupos dbOperaciones dbServicios dbAclGroups dbAclMapService dbAclMapUser dbOficinasClientes dbContactosClientes dbCamadas dbCiudades dbComunas dbDirecciones dbMandantes dbCrossDirecciones dbCrossTelefonos dbCarpetas dbAgendar dbAcciones dbLogAcciones dbErrores dbLogErrores dbLogCarpeta dbParsedFiles dbFastInput dbGeneralSpool)

#echo "deleting old files"
/usr/bin/rm -f "$DIR/*.sql.gz"

echo " " > $FILE
echo "CREATE DATABASE IF NOT EXISTS $DATABASE" >> $FILE
echo "USE $DATABASE;" >> $FILE

#counting element of the array
k=0;
for j in ${TABLES_DB1[@]}; do
k=$[$k+1]
done

# dros the tables, only for secure
while [ $k -gt 0 ]
do
echo "DROP TABLE IF EXISTS ${TABLES_DB1[$j]};" >> $FILE
k=$[$k-1]
done

#make a mysqldump for each table in the orden of creation of tables ,
#no in alfabetics order , son you dont have any constrains error

for i in ${TABLES[@]}; do
$COMMAND -u $USER -p$PASS -a -Q -c --no-autocommit $DATABASE ${i} >> $FILE
echo " " >> $FILE
done

# simple
# enjoy it
# Rafael Avaria G.
# any commnet to : ravaria@excelsium.cl

Options: ReplyQuote


Subject
Views
Written By
Posted
troubles using mysqldump with innodb tables use this simple script
3752
February 01, 2005 09:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.