release
This commit is contained in:
parent
afd2c0613d
commit
1d573a6d47
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
# === CONFIG ===
|
# === CONFIG ===
|
||||||
CONFIG_CHUNK=1000000
|
CONFIG_CHUNK=1000000
|
||||||
|
VERBOSE=0
|
||||||
|
|
||||||
# === DO NOT EDIT BELOW THIS LINE ===
|
# === DO NOT EDIT BELOW THIS LINE ===
|
||||||
|
|
||||||
|
@ -10,7 +11,11 @@ if [ ! -n "$BASH" ] ;then echo Please run this script $0 with bash; exit 1; fi
|
||||||
# === FUNCTIONS ===
|
# === FUNCTIONS ===
|
||||||
f_log()
|
f_log()
|
||||||
{
|
{
|
||||||
echo "RESTORE: $@"
|
echo "RESTORE: $@"
|
||||||
|
|
||||||
|
if [ $VERBOSE -eq 1 ]; then
|
||||||
|
echo "RESTORE: $@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restore()
|
restore()
|
||||||
|
@ -32,7 +37,7 @@ restore()
|
||||||
time mysql --defaults-extra-file=$CONFIG_FILE < $DIR/__create.sql 2>/dev/null
|
time mysql --defaults-extra-file=$CONFIG_FILE < $DIR/__create.sql 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tables=$(ls -1 $DIR | grep -v __ | awk -F. '{print $1}' | sort | uniq)
|
tables=$(ls -1 $DIR | grep -v __ | grep -v _part_ | awk -F. '{print $1}' | sort | uniq)
|
||||||
|
|
||||||
f_log "Create tables in $BDD"
|
f_log "Create tables in $BDD"
|
||||||
for TABLE in $tables; do
|
for TABLE in $tables; do
|
||||||
|
@ -58,23 +63,31 @@ restore()
|
||||||
|
|
||||||
if [ -f "$DIR/$TABLE.txt" ]; then
|
if [ -f "$DIR/$TABLE.txt" ]; then
|
||||||
f_log "+ $TABLE"
|
f_log "+ $TABLE"
|
||||||
split -l $CONFIG_CHUNK "$DIR/$TABLE.txt" ${TABLE}_part_
|
|
||||||
for segment in ${TABLE}_part_*; do
|
split -l $CONFIG_CHUNK "$DIR/$TABLE.txt" "$DIR/${TABLE}_part_"
|
||||||
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;
|
for segment in "$DIR/${TABLE}"_part_*; do
|
||||||
LOAD DATA LOCAL INFILE '$segment'
|
f_log "Restore from $segment"
|
||||||
INTO TABLE $TABLE;
|
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;
|
||||||
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
LOAD DATA LOCAL INFILE '$segment'
|
||||||
rm $segment
|
INTO TABLE $TABLE;
|
||||||
done
|
SET foreign_key_checks = 1; SET unique_checks = 1; SET sql_log_bin = 1;"
|
||||||
if [ ! -f "$DIR/$TABLE.txt.bz2" ]; then
|
done
|
||||||
f_log "> $TABLE"
|
|
||||||
bzip2 $DIR/$TABLE.txt
|
if [ -f "$segment" ]; then
|
||||||
fi
|
f_log "Delete segment $segment"
|
||||||
|
rm "$segment"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$DIR/$TABLE.txt.bz2" ]; then
|
||||||
|
f_log "> $TABLE"
|
||||||
|
bzip2 $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/$BDD/$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]"
|
||||||
|
@ -86,16 +99,16 @@ restore()
|
||||||
|
|
||||||
if [ -f "$DIR/__routines.sql" ]; then
|
if [ -f "$DIR/__routines.sql" ]; then
|
||||||
f_log "Import routines into $BDD"
|
f_log "Import routines into $BDD"
|
||||||
time mysql --defaults-extra-file=$CONFIG_FILE $BDD < $DIR/__routines.sql 2>/dev/null
|
mysql --defaults-extra-file=$CONFIG_FILE $BDD < $DIR/__routines.sql 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$DIR/__views.sql" ]; then
|
if [ -f "$DIR/__views.sql" ]; then
|
||||||
f_log "Import views into $BDD"
|
f_log "Import views into $BDD"
|
||||||
time mysql --defaults-extra-file=$CONFIG_FILE $BDD < $DIR/__views.sql 2>/dev/null
|
mysql --defaults-extra-file=$CONFIG_FILE $BDD < $DIR/__views.sql 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
f_log "Flush privileges;"
|
f_log "Flush privileges;"
|
||||||
time mysql --defaults-extra-file=$CONFIG_FILE -e "flush privileges;"
|
mysql --defaults-extra-file=$CONFIG_FILE -e "flush privileges;"
|
||||||
|
|
||||||
f_log "** END **"
|
f_log "** END **"
|
||||||
|
|
||||||
|
@ -126,6 +139,8 @@ EOF
|
||||||
# exit;
|
# exit;
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
|
BACKUP_DIR=$(pwd)
|
||||||
|
|
||||||
BIN_DEPS="ls grep awk sort uniq bunzip2 bzip2 mysql"
|
BIN_DEPS="ls grep awk sort uniq bunzip2 bzip2 mysql"
|
||||||
|
|
||||||
if [ -f '/etc/debian_version' ]; then
|
if [ -f '/etc/debian_version' ]; then
|
||||||
|
@ -171,6 +186,14 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# === AUTORUN ===
|
# === SETTINGS ===
|
||||||
restore $(pwd)
|
f_log "============================================"
|
||||||
|
f_log "Restore from: $BACKUP_DIR"
|
||||||
|
f_log "Config file: $CONFIG_FILE"
|
||||||
|
f_log "Verbose: $VERBOSE"
|
||||||
|
f_log "============================================"
|
||||||
|
f_log ""
|
||||||
|
|
||||||
|
# === AUTORUN ===
|
||||||
|
restore $BACKUP_DIR
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue