---
# System prepended metadata

title: 'DB Migration strategy:'

---

# DB Migration strategy:

Step 1: Add replica machine in GCP
Step 2: Create new Secret branch from manish/branch and update mongo ids

Step 3: Stop all 7 apocalypse machine + lambda + GCP
  Blessy - 1, 6, Lambda - DONE
  Hitesh - 5, 7, GCP - Done
  **Riyaz - 2, 3, 4 - DONE**
Step 4: Shut down dashboard nginx - dashboard-old, pro.shopdeck.com & seller app
  Rahul - Both NGINX  - DONE
Step 5: Shut down all the DAGs - DONE
  Cron - Shubham
  Dag - Shubham
  Airflow Analytics - Shubham
  Gabriel - Shubham
Step 6: Deploy website with maintenance page enabled
  Rahul 
Step 7: After Step 3, 4, 5, 6 all traffic should be zero. Check kibana for 5 minutes

Step 7.5: Upgrade GCP replica databases to primary
    Manish
step 7.6: PSQL copy commands
    Hitesh

Step 8: Redeploy dashboard side backend - AWS
Step 9: Redeploy consumer side backend - AWS
Step 10: Redeploy dag
Step 11: Restart all 6 apocalypse machine
Step 12: Redeploy dashboard side backend - GCP
Step 13: Redeploy website side backend - AWS
Step 14: Redeploy website side backend - GCP
Step 15: Enable dashboard-old and pro.shopdeck nginx
Step 16: Enable website



# DB Steps

- Aadesh
1\. ssh ubuntu@3.110.201.146
2\. mongo
// remove AWS replica
3\. rs.remove("172.31.9.11:27017")
4\. cfg = rs.conf()
// reduce primary priority
5\. cfg.members\[2\].priority = 1
6\. rs.reconfig(cfg)

gcloud dns --project=blitzscale-prod-project record-sets update aadeshprimary.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.1.0.9"
gcloud dns --project=blitzscale-prod-project record-sets update aadeshreplica1.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.3.0.20"

Chnage AWS side route 53 changes
\- aadeshprimary.prod	172.31.42.84  10.1.0.9
\- aadeshreplica1.prod	172.31.9.11  10.3.0.20



- Soochi
1\. ssh ubuntu@65.1.111.162
2\. mongo
// remove AWS replica
3\. rs.remove("172.31.1.94:27017")
4\. cfg = rs.conf()
// reduce primary priority
5\. cfg.members\[0\].priority = 1
6\. rs.reconfig(cfg)

gcloud dns --project=blitzscale-prod-project record-sets update soochiprimary.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.1.0.11"
gcloud dns --project=blitzscale-prod-project record-sets update soochireplica1.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.3.0.31"

soochiprimary.prod	172.31.7.232  10.1.0.11
soochireplica1.prod	172.31.1.94  10.3.0.31


- Aadhar
1\. ssh ubuntu@3.110.119.184
2\. mongo
// remove AWS replica
3\. rs.remove("172.31.4.74:27017")
4\. cfg = rs.conf()
// reduce primary priority
5\. cfg.members\[0\].priority = 1
6\. rs.reconfig(cfg)

gcloud dns --project=blitzscale-prod-project record-sets update aadharprimary.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.1.0.10"
gcloud dns --project=blitzscale-prod-project record-sets update aadharreplica1.prod. --zone="prod" --type="A" --ttl="60" --rrdatas="10.3.0.30"

aadharprimary.prod	172.31.0.88  10.1.0.10
aadharreplica1.prod	172.31.4.74  10.3.0.30
