Database Copy Script:
#!/bin/bash
#: Title : Copy database
#: Description : 데이터베이스 복사해오기
LOGFILE=""
TODAY=$(date '+%Y%m%d')
DB_HOST="***" # 복사할 Public IP
DB_PORT="***"
USERID="***"
PASSWD="***"
DB_NAME="***"
START_DATE=$(date '+%Y%m%d-%H%M%S')
START=$(date '+%Y%m%d%H%M%S')
mkdir -p "${START_DATE}"
echo "==============================================================="
echo "start time : $START_DATE"
mysqldump --lock-tables=false --single-transaction -h $DB_HOST -P $DB_PORT -u $USERID -p$PASSWD --databases $DB_NAME > ./${DB_NAME}_new_$START.sql
mysqldump --lock-tables=false --single-transaction --no-data -h $DB_HOST -P $DB_PORT -u $USERID -p$PASSWD --databases $DB_NAME > ./${START_DATE}/${DB_NAME}_ddl.sql
mysqldump --lock-tables=false --single-transaction --no-create-db --no-create-info -h $DB_HOST -P $DB_PORT -u $USERID -p$PASSWD --databases $DB_NAME > ./${START_DATE}/${DB_NAME}_dml.sql
END_DATE=$(date '+%Y%m%d-%H%M%S')
echo "end time : $END_DATE"
echo "==============================================================="
Database Paste Script:
#!/bin/bash
#: Title : Paste database
#: Description : 복사한 데이터베이스 붙여넣기
DB_HOST="***" # 붙여넣을 Public IP
DB_PORT="***"
USERID="***"
PASSWD="***"
DB_NAME="***"
START_DATE=$(date '+%Y%m%d-%H%M%S')
echo "==============================================================="
echo "start time : $START_DATE"
mysql -h $DB_HOST -P $DB_PORT -u $USERID -p$PASSWD --database $DB_NAME < "$1"
END_DATE=$(date '+%Y%m%d-%H%M%S')
echo "end time : $END_DATE"
echo "==============================================================="