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