-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Set variables for database names, container names, and password | ||
PROD_DB_CONTAINER="blumy-production-db-1" | ||
TEST_DB_CONTAINER="blumy-test-db-1" | ||
DB_USER="blumy" | ||
DB_NAME="blumy" | ||
DB_PASSWORD="blumy" | ||
|
||
# Step 1: Create a dump of the production database and restore it to the test database | ||
echo "Creating production database dump and restoring it to the test database..." | ||
ssh Blumy << EOF | ||
# Dump the production database and directly pipe it to the test database | ||
docker exec -e PGPASSWORD=${DB_PASSWORD} ${PROD_DB_CONTAINER} pg_dump -U ${DB_USER} --clean --if-exists ${DB_NAME} | docker exec -e PGPASSWORD=${DB_PASSWORD} -i ${TEST_DB_CONTAINER} psql -U ${DB_USER} -d ${DB_NAME} | ||
EOF | ||
|
||
echo "Database synchronization complete." |