-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathrenew-pgsql-infra.sh
More file actions
executable file
·48 lines (40 loc) · 1.42 KB
/
renew-pgsql-infra.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Script to renew the PostgreSQL container (pgsql-infra)
# This will remove all existing data and restart the container
set -e # Exit on error
echo "=========================================="
echo "Recreating PostgreSQL Container (pgsql-infra)"
echo "=========================================="
echo ""
# Check if docker-compose.yml exists
if [ ! -f "docker-compose.yml" ]; then
echo "Error: docker-compose.yml not found in current directory"
echo "Please run this script from the db-samples directory"
exit 1
fi
# Stop and remove containers
echo "1. Stopping and removing existing PostgreSQL container..."
docker-compose stop postgres
docker-compose rm -f postgres
# Remove the volume to ensure fresh data
echo ""
echo "2. Removing data volume for fresh installation..."
docker volume rm db-samples_postgres_data 2>/dev/null || echo " (No existing volume to remove)"
# Start the service
echo ""
echo "3. Starting PostgreSQL container..."
docker-compose up -d postgres
if [ $? -eq 0 ]; then
echo ""
echo "=========================================="
echo "✓ Success!"
echo "=========================================="
echo "pgsql-infra container is running."
echo "To stop: docker-compose down"
echo "=========================================="
else
echo ""
echo "✗ Failed to start pgsql-infra container"
echo "Check logs with: docker-compose logs postgres"
exit 1
fi