first commit
This commit is contained in:
parent
f30268f11c
commit
0cc976d8bb
6 changed files with 16 additions and 16 deletions
|
|
@ -4,9 +4,9 @@ set -e
|
|||
# -----------------------------
|
||||
# INPUTS
|
||||
# -----------------------------
|
||||
CONTAINER_NAME="54e"
|
||||
CONTAINER_NAME="meatfarmer-db"
|
||||
DB_PORT="5432"
|
||||
DB_NAME="mytestdb"
|
||||
DB_NAME="meatfarmer"
|
||||
|
||||
# -----------------------------
|
||||
# VALIDATION
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
services:
|
||||
postgres-replica:
|
||||
meatfarmer-db:
|
||||
image: postgres:17
|
||||
container_name: postgres-replica
|
||||
container_name: meatfarmer-db
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "7447:5432"
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: mytestdb
|
||||
POSTGRES_PASSWORD: meatfarmer_master_password
|
||||
POSTGRES_DB: meatfarmer
|
||||
volumes:
|
||||
- ./data:/var/lib/postgresql/data
|
||||
- ./postgresql.conf:/etc/postgresql/postgresql.conf:ro
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
|||
DO \$\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_roles WHERE rolname = 'replicator'
|
||||
SELECT 1 FROM pg_roles WHERE rolname = 'meatfarmer_replicator'
|
||||
) THEN
|
||||
CREATE ROLE replicator
|
||||
WITH REPLICATION
|
||||
LOGIN
|
||||
PASSWORD 'replicator_password';
|
||||
PASSWORD 'meatfarmer_replicator_password';
|
||||
END IF;
|
||||
END
|
||||
\$\$;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ host all all 127.0.0.1/32 trust
|
|||
host all all ::1/128 trust
|
||||
|
||||
# Allow replication user from primary
|
||||
host replication replicator 0.0.0.0/0 md5
|
||||
host replication meatfarmer_replicator 0.0.0.0/0 md5
|
||||
|
||||
host mytestdb postgres 0.0.0.0/0 md5
|
||||
host meatfarmer postgres 0.0.0.0/0 md5
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
postgres-replica:
|
||||
meatfarmer-db:
|
||||
image: postgres:17
|
||||
container_name: postgres-replica
|
||||
container_name: meatfarmer-db
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "7447:5432"
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ set -e
|
|||
# -----------------------------
|
||||
# INPUTS
|
||||
# -----------------------------
|
||||
CONTAINER_NAME="$1"
|
||||
DB_PORT="$2"
|
||||
DUMP_FILE="$3"
|
||||
CONTAINER_NAME="meatfarmer-db"
|
||||
DB_PORT="5432"
|
||||
DUMP_FILE="$1"
|
||||
|
||||
# -----------------------------
|
||||
# VALIDATION
|
||||
|
|
@ -39,7 +39,7 @@ docker exec -i "$CONTAINER_NAME" \
|
|||
--if-exists \
|
||||
--no-owner \
|
||||
--no-privileges \
|
||||
-d postgres < "$DUMP_FILE"
|
||||
-d meatfarmer < "$DUMP_FILE"
|
||||
|
||||
echo "Restore completed successfully."
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue