Fixed bugs with default charset
This commit is contained in:
parent
6cd7eb5427
commit
40266a4d46
20
restore.sh
Executable file → Normal file
20
restore.sh
Executable file → Normal file
|
@ -113,23 +113,17 @@ restore()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "$DIR/$BDD/$TABLE.txt" ]; then
|
if [ -s "$DIR/$BDD/$TABLE.txt" ]; then
|
||||||
|
|
||||||
if [ ! -z "$(cat $DIR/$BDD/$TABLE.sql | grep -i 'DEFAULT CHARSET=CP1251')" ]; then
|
f_log "+ $TABLE"
|
||||||
charset='cp1251'
|
|
||||||
else
|
|
||||||
charset='utf8'
|
|
||||||
fi
|
|
||||||
|
|
||||||
f_log "+ $TABLE, Set default charset: $charset"
|
|
||||||
|
|
||||||
split -l $CONFIG_CHUNK "$DIR/$BDD/$TABLE.txt" "$DIR/$BDD/${TABLE}_part_"
|
split -l $CONFIG_CHUNK "$DIR/$BDD/$TABLE.txt" "$DIR/$BDD/${TABLE}_part_"
|
||||||
for segment in "$DIR/$BDD/${TABLE}"_part_*; do
|
for segment in "$DIR/$BDD/${TABLE}"_part_*; do
|
||||||
f_log "Restore from $segment"
|
f_log "Restore from $segment"
|
||||||
mysql --defaults-extra-file=$CONFIG_FILE $BDD --local-infile -e "SET foreign_key_checks = 0; SET unique_checks = 0; SET sql_log_bin = 0;
|
mysql --defaults-extra-file=$CONFIG_FILE $BDD --local-infile -e "SET foreign_key_checks = 0; SET unique_checks = 0; SET sql_log_bin = 0;
|
||||||
SET character_set_database = $charset;
|
SET character_set_filesystem=utf8;
|
||||||
LOAD DATA LOCAL INFILE '$segment'
|
LOAD DATA LOCAL INFILE '$segment'
|
||||||
INTO TABLE $TABLE;
|
INTO TABLE $TABLE;
|
||||||
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
||||||
|
|
||||||
if [ -f "$segment" ]; then
|
if [ -f "$segment" ]; then
|
||||||
f_log "Delete segment $segment"
|
f_log "Delete segment $segment"
|
||||||
|
|
66
restore_db.sh
Executable file → Normal file
66
restore_db.sh
Executable file → Normal file
|
@ -68,47 +68,41 @@ restore()
|
||||||
bunzip2 -k $DIR/$TABLE.txt.bz2
|
bunzip2 -k $DIR/$TABLE.txt.bz2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "$DIR/$TABLE.txt" ]; then
|
if [ -s "$DIR/$TABLE.txt" ]; then
|
||||||
|
|
||||||
if [ ! -z "$(cat $DIR/$BDD/$TABLE.sql | grep -i 'DEFAULT CHARSET=CP1251')" ]; then
|
f_log "+ $TABLE"
|
||||||
charset='cp1251'
|
|
||||||
else
|
|
||||||
charset='utf8'
|
|
||||||
fi
|
|
||||||
|
|
||||||
f_log "+ $TABLE, Set default charset: $charset"
|
|
||||||
|
|
||||||
split -l $CONFIG_CHUNK "$DIR/$TABLE.txt" "$DIR/${TABLE}_part_"
|
split -l $CONFIG_CHUNK "$DIR/$TABLE.txt" "$DIR/${TABLE}_part_"
|
||||||
for segment in "$DIR/${TABLE}"_part_*; do
|
for segment in "$DIR/${TABLE}"_part_*; do
|
||||||
f_log "Restore from $segment"
|
f_log "Restore from $segment"
|
||||||
time mysql --defaults-extra-file=$CONFIG_FILE $BDD --local-infile -e "SET foreign_key_checks = 0; SET unique_checks = 0; SET sql_log_bin = 0;
|
mysql --defaults-extra-file=$CONFIG_FILE $BDD --local-infile -e "SET foreign_key_checks = 0; SET unique_checks = 0; SET sql_log_bin = 0;
|
||||||
SET character_set_database = $charset;
|
SET character_set_database=utf8;
|
||||||
LOAD DATA LOCAL INFILE '$segment'
|
LOAD DATA LOCAL INFILE '$segment'
|
||||||
INTO TABLE $TABLE;
|
INTO TABLE $TABLE;
|
||||||
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
||||||
|
|
||||||
if [ -f "$segment" ]; then
|
|
||||||
f_log "Delete segment $segment"
|
|
||||||
rm "$segment"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -f "$DIR/$TABLE.txt.bz2" ]; then
|
if [ -f "$segment" ]; then
|
||||||
f_log "Delete source file: $TABLE.txt"
|
f_log "Delete segment $segment"
|
||||||
rm $DIR/$TABLE.txt
|
rm "$segment"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -f "$DIR/$TABLE.txt.bz2" ]; then
|
||||||
|
f_log "Delete source file: $TABLE.txt"
|
||||||
|
rm $DIR/$TABLE.txt
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $DATABASES_TABLE_CHECK ]; then
|
if [ $DATABASES_TABLE_CHECK ]; then
|
||||||
if [ -f "$DIR/$BDD/$TABLE.ibd" ]; then
|
if [ -f "$DIR/$BDD/$TABLE.ibd" ]; then
|
||||||
if [ ! $(innochecksum $DIR/$TABLE.ibd) ]; then
|
if [ ! $(innochecksum $DIR/$TABLE.ibd) ]; then
|
||||||
f_log "$TABLE [OK]"
|
f_log "$TABLE [OK]"
|
||||||
else
|
else
|
||||||
f_log "$TABLE [ERR]"
|
f_log "$TABLE [ERR]"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue