DevOps

Updated 4 months ago by Sam Joseph
Heroku

Seems like there are simpler ways to do this - check out:


heroku pg:pull HEROKU_POSTGRESQL_AQUA_URL ls_development -r production


The heroku command to copy the production data to the staging server:

heroku pg:backups capture -r production
heroku pg:backups restore 
`heroku pg:backups public-url -a harrowcn-production`
HEROKU_POSTGRESQL_CYAN_URL -r staging

Commands to get production data on local machine

curl -o latest.dump `heroku pg:backups public-url -r production`
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d ls_development latest.dump

Console commands to check status of organization emails and latitude (data from Oct 4th 2013)

heroku run rails console --remote staging
Organization.where("email !=''").count ==> 72
Organization.where("email =''").count ==> 42
Organization.where("email IS NULL").count  ==> 526
Organization.where("latitude IS NULL").count ==> 26

The heroku command to run the email import on the staging server

heroku run bundle exec rake db:import:emails[db/emails.csv] --remote staging

The heroku command to run the email import (and db stuff) on the production server

heroku run rake db:migrate --remote production
heroku run rake db:pages --remote production
heroku run bundle exec rake db:import:emails[db/emails.csv] --remote production

Ninefold


transfering prod data to staging

/usr/local/bin/pg_dump -h <PROD_DB_IP> -p 5432 -U app -a -N postgis -N topology -Fc -d localsupport > prod_backup.dump
/usr/local/bin/pg_restore -h <STAG_DB_IP> -p 5432 -U app -d db7071 prod_backup.dump



Might encounter import issues with sequences:

db7071=> SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
             relname             
---------------------------------
 topology_id_seq
 categories_id_seq
 users_id_seq
 pages_id_seq
 organisations_id_seq
 categories_organisations_id_seq
 volunteer_ops_id_seq
 features_id_seq
(8 rows)

db7071=> SELECT pg_catalog.setval('users_id_seq', 370, true);
 setval 
--------
    370
(1 row)

Migrating from Ninefold to Heroku

/usr/local/bin/pg_dump -h DATABASE_IP -p 5432 -U app -N postgis -N topology -d localsupport -Fc -f <DROPBOX FILE>
heroku pg:reset HEROKU_POSTGRESQL_GREEN -r develop
heroku pg:backups restore '<DROPBOX_URL>' DATABASE -a harrowcn-develop -r develop

Revisions

comments powered by Disqus