Hello Ted! Peter Cock wrote, On 03/25/2013 01:51 PM:
On Mon, Mar 25, 2013 at 5:41 PM, Ted Goldstein <tedgoldstein@gmail.com> wrote:
Hi Does anyone have any experience or advice about running two servers on the same database?
My advice is don't do it.
I'll second Peter's advice, don't ever do that :) I forgot where I heard it, but someone (wise) said "Code flows from dev to prod, data should flow from prod to dev". To facilitate that, we use the following script, that can quickly copy the data from our production server to our development server. Once it's run, the databases contain the same datasets and workflows and everything, making testing and debugging much easier: === #!/bin/sh DATE=$(date "+%Y_%m_%d_%H%M%S") FILE="galaxy_db_prod_to_devel_${DATE}.sql.gz" DEST=/tmp/ FILE="${DEST}${FILE}" echo "Dumping Prod-DB to:" echo " $FILE" echo "(Enter 'galaxyprod' DB password)" pg_dump -c -U galaxyprod galaxyprod | sed 's/galaxyprod/galaxydev/g' | gzip > "$FILE" || exit 1 echo echo "Dropping and re-creating Galaxy-Devel database." echo "press CTRL-C to abort or ENTER to continue." read ## First, drop all tables, functions, etc. psql -t -d galaxydev -c "SELECT 'DROP TABLE ' || n.nspname || '.' ||c.relname || ' CASCADE;' FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid)" | psql galaxydev zcat "$FILE" | psql galaxydev || exit 1 ## Reset all the waiting jobs, we don't want to re-run them on dev psql galaxydev -c "update job set state='error' where (state='new' or state='waiting');" rm "$FILE" === Once this script is complete, the "galaxydev" database is an exact copy of "galaxyprod" database (except queued jobs). Hope this helps, -gordon