Как мне реализовать репликацию? У меня есть master db в docker контейнере и есть локальная бд (Slave DB, к которой можно подключиться следующим образом: psql "postgresql://gen_user:%3D%3A%5Cc%3B%2F%246~ieZTz@192.168.0.4:5432/default_db"), как мне сделать репликацию из master db в slave db? Python, docker-compose.yml, django. У меня есть backup контейнер, который создает бэкап бд в каждые 2 часа ночи.
Вот мой docker-compose.yml:
services:
  redis:
    image: redis
    environment:
      - REDIS_PASSWORD=${REDIS_PASSWORD}
    command: [ "redis-server", "--requirepass", "${REDIS_PASSWORD}" ]
    networks:
      - backend_network
    restart: unless-stopped

  db:
    image: postgres:16.4
    env_file:
      - .env
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - '5433:5432'
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - backend_network
    restart: unless-stopped

  app:
    build: .
    tty: true
    command: >
      sh -c "python manage.py migrate --noinput && 
             python manage.py collectstatic --noinput &&
             gunicorn config.wsgi:application --bind 0.0.0.0:8000"
    ports:
      - "8000:8000"
    env_file:
      - .env
    volumes:
      - .:/code
      - static-files:/code/static
      - media-files:/code/media
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - backend_network
      - nginx_network
    restart: unless-stopped

  backup:
    build: ./backup
    env_file:
      - .env
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./backups:/backups
    depends_on:
      - db
      - app
    networks:
      - backend_network
    restart: unless-stopped

  celery:
    build: .
    tty: true
    command: celery -A config worker -l INFO
    volumes:
      - media-files:/code/media
    depends_on:
      - redis
      - app
    networks:
      - backend_network
    restart: unless-stopped

  celery-beat:
    build: .
    tty: true
    command: celery -A config beat -l INFO
    env_file:
      - .env
    volumes:
      - media-files:/code/media
    depends_on:
      - redis
      - app
    networks:
      - backend_network
    restart: unless-stopped

volumes:
  static-files:
    external: true
  pgdata:
    name: "pgdata"
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: 'pgdata'
  media-files:
    name: "media-files"
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: 'media'

networks:
  backend_network:
    driver: bridge
  nginx_network:
    name: "nginx_network"
    external: true

**dockerfile backup**:
FROM postgres:16.4

RUN apt-get update && apt-get install -y \
    cron \
    postgresql-client \
    && rm -rf /var/lib/apt/lists/*

COPY backup.sh /usr/local/bin/backup.sh

RUN chmod +x /usr/local/bin/backup.sh

COPY backup-cron /etc/cron.d/backup-cron

RUN chmod 0644 /etc/cron.d/backup-cron

RUN crontab /etc/cron.d/backup-cron

RUN touch /var/log/cron.log

CMD cron && tail -f /var/log/cron.log

**backup-cron**:
0 2 * * * /usr/local/bin/backup.sh >> /var/log/cron.log 2>&1

**backup.sh**:
#!/bin/bash

export PGPASSWORD="PassPass"

BACKUP_PATH="/backups/pg_backup_$(date +\%Y-\%m-\%d_\%H-\%M-\%S).sql"
echo "Starting database backup..."
pg_dump -U postgres -h db -d postgres > $BACKUP_PATH

if [ $? -eq 0 ]; then
    echo "Backup finished successfully. Stored at $BACKUP_PATH"
else
    echo "Backup failed."
fi

unset PGPASSWORD