From e86122cb3e3f748b21405c7e53a98c79aadd3018 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 20 Jul 2017 12:37:47 +1000 Subject: [PATCH 1/2] Exclude session data when mirroring data Probably a better long term solution would be to add a job to clean up old session data on the server, but this is a quick & dirty fix to speed mirroring up on a slow connection. --- script/mirror_db.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/mirror_db.sh b/script/mirror_db.sh index 4c6142b701..78dac43962 100755 --- a/script/mirror_db.sh +++ b/script/mirror_db.sh @@ -18,12 +18,13 @@ else DB_DATABASE='openfoodnetwork' fi +DB_OPTIONS='--exclude-table-data=sessions' # -- Mirror database echo "Mirroring database..." echo "drop database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test echo "create database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test -ssh $1 "pg_dump -h localhost -U $DB_USER $DB_DATABASE |gzip" |gunzip |psql -h localhost -U ofn open_food_network_dev +ssh $1 "pg_dump -h localhost -U $DB_USER $DB_DATABASE $DB_OPTIONS |gzip" |gunzip |psql -h localhost -U ofn open_food_network_dev # -- Disable S3 From 8fe6800151e910069e3e24a5c9541fd3dfc2bcb2 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 27 Jul 2017 12:58:11 +1000 Subject: [PATCH 2/2] Add documentation to the top of mirror_db script --- script/mirror_db.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/mirror_db.sh b/script/mirror_db.sh index 78dac43962..88e4684306 100755 --- a/script/mirror_db.sh +++ b/script/mirror_db.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Used to pull data from production or staging servers into local dev database +# Useful for when you want to test a migration against production data, or see +# the effect of codebase changes on real-life data + # Usage: script/mirror_db.sh [ofn-staging1|ofn-staging2|ofn-prod] set -e