We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f055745 commit 2c1adefCopy full SHA for 2c1adef
db/copy_prod_over_staging.sh
@@ -0,0 +1,13 @@
1
+#! /bin/bash
2
+
3
+# Use `fly proxy 5432 &` to let the below commands connect to the database.
4
5
+# We expect .env to set $COOKBOOK_PROD_WEBSERVER_PASSWORD and $COOKBOOK_STAGING_ADMIN_PASSWORD.
6
+. .env
7
8
+PROD_DATABASE_URL="postgres://cookbook_prod_webserver:${COOKBOOK_PROD_WEBSERVER_PASSWORD}@localhost:5432/cookbook_prod?sslmode=disable"
9
+STAGING_DATABASE_URL="postgres://cookbook_staging_admin:${COOKBOOK_STAGING_ADMIN_PASSWORD}@localhost:5432/cookbook_staging?sslmode=disable"
10
11
+pg_dump --clean --if-exists -O -d "$PROD_DATABASE_URL" | \
12
+ sed 's/cookbook_prod/cookbook_staging/g' | \
13
+ pg_restore -d "$STAGING_DATABASE_URL" --single-transaction
0 commit comments