@ -17,7 +17,6 @@ echo $DATE
@@ -17,7 +17,6 @@ echo $DATE
#systemctl is-active --quiet platform5.service && systemctl stop platform5
#systemctl is-active --quiet platform6.service && systemctl stop platform6
if [ [ " $PLATFORM_STATUS " = = 1 ] ] ; then
echo " echo PLATFORM_STATUS= $PLATFORM_STATUS "
echo " Stopping $PLATFORM_SERVICE_NAME "
@ -37,14 +36,11 @@ download_platform(){
@@ -37,14 +36,11 @@ download_platform(){
yes | sshpass -p " $DESTINATION_PASSWORD " rsync -e " ssh -p $DESTINATION_PORT -o StrictHostKeyChecking=no " -avz --ignore-existing $SOURCE_PLATFORM_PATH /$folder $DESTINATION_USER @$DESTINATION_IP :$DESTINATION_PLATFORM_PATH /
done
yes | sshpass -p " $DESTINATION_PASSWORD " rsync -e " ssh -p $DESTINATION_PORT -o StrictHostKeyChecking=no " -avz --ignore-existing $SOURCE_PLATFORM_PATH /bin/server $DESTINATION_USER @$DESTINATION_IP :$DESTINATION_PLATFORM_PATH /bin/
}
download_platform
DB_BACKUP = $SOURCE_DB_NAME .migration.$DATE .sql
echo "backup name:" $DB_BACKUP
db_backup( ) {
echo EVENT_STORE = $EVENT_STORE
if [ [ " $EVENT_STORE " = = 0 ] ] ; then
@ -58,6 +54,7 @@ db_backup() {
@@ -58,6 +54,7 @@ db_backup() {
else echo "EVENT_STORE value must be 0 or 1 or 2" && exit
fi
}
send_backup( ) {
if [ [ " $EVENT_STORE " = = 0 ] ] || [ [ " $EVENT_STORE " = = 1 ] ] ; then
echo "send dump to the destination"
@ -67,6 +64,7 @@ send_backup() {
@@ -67,6 +64,7 @@ send_backup() {
else echo "no backup, nothing to send"
fi
}
create_and_restore_db( ) {
if [ [ " $EVENT_STORE " = = 0 ] ] || [ [ " $EVENT_STORE " = = 1 ] ] ; then
sed -e " s/DESTINATION_DB_NAME/ ${ DESTINATION_DB_NAME } / " \
@ -81,15 +79,10 @@ change_config(){
@@ -81,15 +79,10 @@ change_config(){
# 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"
#db wo host sshpass -p "$DESTINATION_PASSWORD" ssh $DESTINATION_USER@$DESTINATION_IP -p $DESTINATION_PORT "sed -i \"s|\(jdbc:postgresql://[^:/]*:[0-9]*/\)[^?]*|\1${DESTINATION_DB_NAME}|g\" $DESTINATION_PLATFORM_PATH/conf/db.conf"
sshpass -p " $DESTINATION_PASSWORD " ssh $DESTINATION_USER @$DESTINATION_IP -p $DESTINATION_PORT " sed -i \"s|\(jdbc:postgresql://[^:/]*:[0-9]*/\)[^?]*|\1 ${ INTERNAL_DATABASE_IP } :5432/ ${ DESTINATION_DB_NAME } |g\" $DESTINATION_PLATFORM_PATH /conf/db.conf "
sshpass -p " $DESTINATION_PASSWORD " ssh $DESTINATION_USER @$DESTINATION_IP -p $DESTINATION_PORT " sed -i \"s|\(jdbc:postgresql://[^:/]*:[0-9]*/\)[^?]*|\1 ${ INTERNAL_DATABASE_IP } :5432/ ${ DESTINATION_DB_NAME } |g\" $DESTINATION_PLATFORM_PATH /conf/db.conf "
}
db_backup
send_backup
create_and_restore_db
change_config
evt_full_rsync( ) {
echo " send $SOURCE_EVT to the destination "
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 / $DESTINATION_USER @$DESTINATION_IP :$DESTINATION_PLATFORM_PATH /bin/storage/1/$SOURCE_EVT /
@ -114,6 +107,21 @@ fonts_rsync(){
@@ -114,6 +107,21 @@ fonts_rsync(){
yes | sshpass -p " $DESTINATION_PASSWORD " ssh $DESTINATION_USER @$DESTINATION_IP -p $DESTINATION_PORT -o StrictHostKeyChecking = no " mkdir -p $DESTINATION_PLATFORM_PATH /bin/storage/1/fonts/ "
sshpass -p " $DESTINATION_PASSWORD " rsync -e " ssh -p $DESTINATION_PORT " -avz --ignore-existing $SOURCE_PLATFORM_PATH /bin/storage/1/fonts/ $DESTINATION_USER @$DESTINATION_IP :$DESTINATION_PLATFORM_PATH /bin/storage/1/fonts/
}
if [ [ " $EVT_COMMON " = = 0 ] ] ; then
echo "Download only files from evt/common"
evt_common_files_rsync
elif [ [ " $EVT_COMMON " = = 1 ] ] ; then
echo "Download full evt"
evt_full_rsync
fi
download_platform
db_backup
send_backup
create_and_restore_db
change_config
fonts_rsync
if [ [ " $EVT_COMMON " = = 0 ] ] ; then
@ -131,9 +139,6 @@ else echo "EVENT_COMMON value must be 0 or 1 or 2" && exit
@@ -131,9 +139,6 @@ else echo "EVENT_COMMON value must be 0 or 1 or 2" && exit
fi
mv config.txt config.txt.$DATE
mv config.txt.template config.txt