|
|
|
|
@ -11,6 +11,8 @@ echo $DATE
@@ -11,6 +11,8 @@ echo $DATE
|
|
|
|
|
systemctl is-active --quiet platform5.service && systemctl stop platform5 |
|
|
|
|
systemctl is-active --quiet platform6.service && systemctl stop platform6 |
|
|
|
|
|
|
|
|
|
Backup_name=$SOURCE_DB_NAME.migration.$DATE.sql |
|
|
|
|
echo "backup name:" $Backup_name |
|
|
|
|
db_backup() { |
|
|
|
|
echo EVENT_STORE=$EVENT_STORE |
|
|
|
|
if [[ "$EVENT_STORE" == 0 ]]; then |
|
|
|
|
@ -20,20 +22,34 @@ db_backup() {
@@ -20,20 +22,34 @@ db_backup() {
|
|
|
|
|
echo Making backup with event_store |
|
|
|
|
PGPASSWORD="$SOURCE_DB_PASSWORD" pg_dump -Fc -U postgres $SOURCE_DB_NAME > /var/backups/$SOURCE_DB_NAME.migration.$DATE.sql |
|
|
|
|
elif [[ "$EVENT_STORE" == 2 ]]; then |
|
|
|
|
echo "Не делаем бэкап" |
|
|
|
|
else echo "EVENT_STORE value must be 0 or 1" && exit |
|
|
|
|
echo "don't make db backup" |
|
|
|
|
else echo "EVENT_STORE value must be 0 or 1 or 2" && exit |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
send_backup(){ |
|
|
|
|
send_backup() { |
|
|
|
|
if [[ "$EVENT_STORE" == 0 ]] or [[ "$EVENT_STORE" == 1 ]]; then |
|
|
|
|
echo "send dump to the destination" |
|
|
|
|
echo Sending db backup to destination server |
|
|
|
|
cd /var/backups/ && yes | sshpass -p "$DESTINATION_DATABASE_PASSWORD" scp -P $DESTINATION_DATABASE_PORT -o StrictHostKeyChecking=no $SOURCE_DB_NAME.migration.$DATE.sql $DESTINATION_DATABASE_USER@$DESTINATION_DATABASE_IP:~/ |
|
|
|
|
cd - |
|
|
|
|
else echo "no backup, nothing to send" && exit |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
create_db() { |
|
|
|
|
sed -e "s/DESTINATION_DB_NAME/${DESTINATION_DB_NAME}/" \ |
|
|
|
|
-e "s/DESTINATION_POSTGRES_PASSWORD/${DESTINATION_POSTGRES_PASSWORD}/"\ |
|
|
|
|
create_db.sh.template > create_db.sh |
|
|
|
|
|
|
|
|
|
sshpass -p "$DESTINATION_DATABASE_PASSWORD" ssh -p $DESTINATION_DATABASE_PORT $DESTINATION_DATABASE_USER@$DESTINATION_DATABASE_IP 'bash -s' < create_db.sh |
|
|
|
|
} |
|
|
|
|
#restore_db(){ |
|
|
|
|
# if [[ "$EVENT_STORE" == 0 ]] or [[ "$EVENT_STORE" == 1 ]]; then |
|
|
|
|
# fi |
|
|
|
|
#} |
|
|
|
|
db_backup |
|
|
|
|
send_backup |
|
|
|
|
create_db |
|
|
|
|
#restore_db |
|
|
|
|
|
|
|
|
|
evt_full_rsync(){ |
|
|
|
|
echo "send $SOURCE_EVT to the destination" |
|
|
|
|
@ -61,7 +77,7 @@ fonts_rsync(){
@@ -61,7 +77,7 @@ fonts_rsync(){
|
|
|
|
|
elif [[ "$EVT_COMMON" == 2 ]]; then |
|
|
|
|
echo "Не скачиваю ничего из storage" |
|
|
|
|
evt_full_rsync |
|
|
|
|
else echo "EVENT_COMMON value must be 0 or 1 o 2" && exit |
|
|
|
|
else echo "EVENT_COMMON value must be 0 or 1 or 2" && exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,3 +94,6 @@ sshpass -p "$DESTINATION_DATABASE_PASSWORD" ssh -p $DESTINATION_DATABASE_PORT $D
@@ -78,3 +94,6 @@ sshpass -p "$DESTINATION_DATABASE_PASSWORD" ssh -p $DESTINATION_DATABASE_PORT $D
|
|
|
|
|
#evt_full_rsync |
|
|
|
|
#evt_common_files_rsync |
|
|
|
|
#fonts_rsync |
|
|
|
|
|
|
|
|
|
systemctl is-active --quiet platform5.service && systemctl start platform5 |
|
|
|
|
systemctl is-active --quiet platform6.service && systemctl start platform6 |