The following outlines how to access the badges production server and copy the production database to your local machine to use for development.
ssh to server:
ssh -p 1855 badgesapp.vmhost.psu.edu
The badges application code and db is run with the user badgesapp
. Start a shell session using this account with:
sudo -u badgesapp bash
The badges production database is called badges_production
which can be access via the psql command or dumped via pg_dump
. Run the following to output the database in the pg binary database format.
pg_dump --host localhost --username badges --verbose --clean --no-owner --no-acl --format=c badges_production > /tmp/badges_production.dump
Note: the /tmp/badges_production.dump
can be altered to whatever file name/location you want.
Now copy the the dump file to your local machine using scp
:
scp -P 1855 badgesapp.vmhost.psu.edu:/tmp/badges_production.dump ~/Desktop/
Now we can create a psql database to hold this database and tell the Rails app to use the newly imported.
Run psql as your local user with the pql cli:
psql
At the psql
cli enter:
CREATE DATABASE badges_production_july10;
feel free to rename badges_production_july10
to whatever appropriated
Quit psql
by entering \q
At this point we can import the psql dump file into the new db via:
pg_restore -d badges_production_july10 ~/Desktop/badges_production.dump
there may be warnings here about badges role not existing, which are fine to ignore
The config/database.yml
file has an option to override the development by setting an enviromental variable called BADGES_DEV_DB
. To set open your local profile ~/.bash_profile
and enter along with the other badges app configs:
export BADGES_DEV_DB='badges_production_july10'
Stop the rails development server, get the new enviroment config source ~/.bash_profile
then restart the rails server.
Viola! You should now have a copy of the a production seeded database on your local machine.
P.S.: Please go back and delete the /tmp/badges_production.dump
file on badgesapp.vmhost.psu.edu
for good housekeeping sake.