Generate Production Dump

Create with pg_dump

  1. If there is an existing stopped instance, start it and use it, otherwise follow the ec2 creation steps

    1. Create EC2 with ubuntu 22.04 and 30GB EBS with a new key pair.
    2. Ensure correct saut vpc and ingressSubnet is chosen
    3. Enable public ip
    4. Select saut-prod-ec2-rds-access security group
    5. ssh to instance
    6. Run this scriptsudo apt updatesudo apt install wget
    sudo sh -c
    
    echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
    
    curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
    
    sudo apt update
    
    sudo apt install postgresql-client-15 -y
    
  2. Take the pg_dump

    pg_dump -h prod-database-url -p 5432 -U prod-database-admin -Fc -b -v -f prod_dump.sql -d  sautprod
    

    get password from secrets manager in aws

  3. After copy is done on ec2 - use scp to copy to local

scp -i you-pem-file.pem -r ubuntu@ec2-ip:~/prod_dump.sql .