Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Cloud Foundry Manual Migration Checklist

Sarah Allen edited this page May 18, 2016 · 6 revisions
  • Verify your Cloud Foundry Target organization and space. cf target
    • Changing targets is easily done with the -o and -s flags. Just provide the -o <ORG_NAME> and the -s <SPACE_NAME> when running cf target.
  • Connect to the production database using the cf-ssh tool. This can take a while to properly connect, so be patient.
    • Once connected you should be in a shared tmate session.
  • Download the psql binaries, using the Cloud.gov documentation.
    • Running this command with download the psql binaries and then put them in your path
curl https://s3.amazonaws.com/18f-cf-cli/psql-9.4.4-ubuntu-14.04.tar.gz | tar xvz
PATH="`pwd`/psql/bin:$PATH"

to download a local copy of the database

  • To dump the database to a sql file, type the following command: pg_dump $DATABASE_URL > ./backup.sql. This will save the database to your current working directory.
  • Connect to the server from your local terminal with the cf files command. Make sure you are targeting the *-ssh application when use cf files. The file path starts from the root of the application user's home directory and every CF instance has your pushed files within an app directory. An example for the file created in the previous step would be: cf files openopps-ssh app/backup.sql
  • to load the database locally:
  dropdb midas
  createdb midas
  npm run migrate
  psql midas < ../backup.sql

to sync from production to staging

set $PROD to be the production database credentials

cf target -s prod
export PROD=`cf env openopps | grep "postgres://" | cut -d "\"" -f 4`
echo $PROD

then use cf-ssh on staging to copy the production database

cf target -s staging
export PROD= <paste from above>
pg_dump $PROD > ./prod.sql
psql $DATABASE_URL < prod.sql