AWS RDS Postgres 인스턴스 복제

AWS RDS Postgres 인스턴스 복제

소수의 작은 Postgre 인스턴스를 더 큰 인스턴스로 통합해야 하는 상황에 직면했습니다.

교체가 발생할 때 "이전" db 새 데이터를 "새" db로 복제하는 방법을 알 수 없습니다.

나는 그것을 간단하게하려고 노력할 것입니다 :

old db instance name is X
new db instance is Y

X has 10 GB of data and its takes 15~ minutes to dump & restore
in the meanwhile X receives more data (1-2 MB)

** HOW do i make X replicate data to Y so this data wont get lost ? ** 

덤프 및 복원을 위한 작은 스크립트가 있습니다.

## remote db to remote db

PGPASSWORD=$source_pass pg_dump -h $source_host -d $source_db_name -U $source_user -p $source_port > test.sql

psql postgres://$dest_user:$dest_pass@$dest_host:$dest_port/postgres -c "CREATE DATABASE ${source_db_name}" \
-c "CREATE USER ${source_user} WITH PASSWORD '${source_pass}'" \
-c "ALTER USER "${source_user}" WITH CREATEDB" \
|| echo "database already exists"

psql postgres://$dest_user:$dest_pass@$dest_host:$dest_port/$source_db_name < test.sql \
 && echo "loaded Data succesfuly !" || echo "Couldnt load data"

관련 정보