diff --git a/migration.sh b/migration.sh index 6af26ac..f9d7071 100644 --- a/migration.sh +++ b/migration.sh @@ -24,7 +24,18 @@ if [[ "PLATFORM_STATUS" == 1 ]]; then systemctl stop $PLATFORM_SERVICE_NAME fi +download_platform(){ +# sshpass -p "$DESTINATION_PASSWORD" ssh $DESTINATION_USER@$DESTINATION_IP -p $DESTINATION_PORT "sed -i \"s|\(jdbc:postgresql://localhost:5432/\)[^?]*|\1${DESTINATION_DB_NAME}|g\" $DESTINATION_PLATFORM_PATH/conf/db.conf" + + sshpass -p "$DESTINATION_PASSWORD" ssh $DESTINATION_USER@$DESTINATION_IP -p $DESTINATION_PORT "mv /home/platform5-server /home/platform5-server-${DATE} && mkdir -p /home/platform5-server && mkdir -p /home/platform5-server/storage && mkdir -p /home/platform5-server/storage/1" +PLATFORM_DIRS="conf,lib,opencv,webapp,scripts,SERVER_config.txt,bin/server," + IFS=',' read -r -a array <<< "$PLATFORM_DIRS" + for folder in "${array[@]}"; do + yes | sshpass -p "$DESTINATION_PASSWORD" rsync -e "ssh -p $DESTINATION_PORT -o StrictHostKeyChecking=no" -avz --ignore-existing $SOURCE_PLATFORM_PATH/bin/storage/1/$SOURCE_EVT/$folder $DESTINATION_USER@$DESTINATION_IP:$DESTINATION_PLATFORM_PATH/ + done +} +download_platform DB_BACKUP=$SOURCE_DB_NAME.migration.$DATE.sql echo "backup name:" $DB_BACKUP db_backup() { @@ -111,18 +122,7 @@ fonts_rsync else echo "EVENT_COMMON value must be 0 or 1 or 2" && exit fi -download_platform(){ -# sshpass -p "$DESTINATION_PASSWORD" ssh $DESTINATION_USER@$DESTINATION_IP -p $DESTINATION_PORT "sed -i \"s|\(jdbc:postgresql://localhost:5432/\)[^?]*|\1${DESTINATION_DB_NAME}|g\" $DESTINATION_PLATFORM_PATH/conf/db.conf" - - sshpass -p "$DESTINATION_PASSWORD" ssh $DESTINATION_USER@$DESTINATION_IP -p $DESTINATION_PORT "mv /home/platform5-server /home/platform5-server-${DATE} && mkdir -p /home/platform5-server && mkdir -p /home/platform5-server/storage && mkdir -p /home/platform5-server/storage/1" -PLATFORM_DIRS="conf,lib,opencv,webapp,scripts,SERVER_config.txt,bin/server," - IFS=',' read -r -a array <<< "$PLATFORM_DIRS" - for folder in "${array[@]}"; do - yes | sshpass -p "$DESTINATION_PASSWORD" rsync -e "ssh -p $DESTINATION_PORT -o StrictHostKeyChecking=no" -avz --ignore-existing $SOURCE_PLATFORM_PATH/bin/storage/1/$SOURCE_EVT/$folder $DESTINATION_USER@$DESTINATION_IP:$DESTINATION_PLATFORM_PATH/ - done - -} if [[ "PLATFORM_STATUS" == 1 ]]; then