db-syncer
is a shell script that automates the synchronization of PostgreSQL databases using Docker Compose. It dynamically generates a docker-compose.yml
file based on environment-specific configurations and syncs remote PostgreSQL databases into local instances.
- Docker: Ensure Docker is installed.
- Docker Compose: Ensure Docker Compose is installed.
-
Clone the Repository 📥:
git clone https://github.com/pinkynrg/db-syncer.git cd db-syncer
-
Set Up Environment Files 📝:
Create a
.env-*
file in theenvs
directory for each environment. For example.env-test-1
:LOCAL_POSTGRES_USER=local_user LOCAL_POSTGRES_PASSWORD=local_password LOCAL_POSTGRES_DB=local_db REMOTE_POSTGRES_HOST=remote.host.com REMOTE_POSTGRES_USER=remote_user REMOTE_POSTGRES_PASSWORD=remote_password REMOTE_POSTGRES_DB=remote_db
-
Run the Script
▶️ :sh ./sync.sh
-
Monitor and Access 👀: The synchronization process will run in the foreground. Access the synced data in your local PostgreSQL database.