incorporating latest data.
pg_dump -Fc --verbose --no-acl --no-owner -c -h localhost -p 5432 libval_development > ~/Documents/20151110_2.dump
for restoring on mbp, tried this
postgres pg_restore --create --clean -d postgres /path/to/dbbackup.dump
this hung. so canceled and then tried this:
pg_restore -v -d libval_development -a ~/Documents/20151110_2.dump > ~/Documents/20151110_2.log 2>&1
this was almost instantaneous, took a few seconds. but db wasn't actually loaded. so,
rake db:drop; rake db:create; rake db:migrate
then tried again. it's hanging on flows.
pg_restore -v -d libval_development -a ~/Documents/20151110_2.dump > ~/Documents/20151110_2_2.log 2>&1
comparing the log files for each try: they seem to have similar errors.
heroku pg:backups restore 'https//aws...'
is hanging at 1.25GB. UPDATE: was a success, took around 20 minutes.
but the weirdest thing has happened for mbp: data for two tables (actual_productions and actual_sheets) has not been copied over. these are fairly recently created tables. there was some intricacy in these tables because their names were changed from two other tables that were then deleted. here is some of the log file:
pg_restore: processing data for table "actual_productions" pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 3408; 0 50939 TABLE DATA actual_productions allen pg_restore: [archiver (db)] COPY failed for table "actual_productions": ERROR: insert or update on table "actual_productions" violates foreign key constraint "fk_rails_473c650b37" DETAIL: Key (production_id)=(1) is not present in table "productions". pg_restore: executing SEQUENCE SET actual_productions_id_seq pg_restore: processing data for table "actual_sheets" pg_restore: [archiver (db)] Error from TOC entry 3410; 0 50944 TABLE DATA actual_sheets allen pg_restore: [archiver (db)] COPY failed for table "actual_sheets": ERROR: insert or update on table "actual_sheets" violates foreign key constraint "fk_rails_33f075fa1e" DETAIL: Key (sheet_id)=(1) is not present in table "sheets". pg_restore: executing SEQUENCE SET actual_sheets_id_seq pg_restore: processing data for table "affiliation_types"
so scrapped that db and started again; drop, create and migrate, then
pg_restore -v -d libval_development -c -C ~/Documents/20151110_2.dump > ~/Documents/20151110_c_C.log 2>&1
seems to be working because it seems to have familiar log, including hanging at (around 10:12pm):
pg_restore: processing data for table "***_rankings"
UPDATE: 11/11/2015 10:34AM
messing around with the pg_dump options, including taking out --clean and --create, or using --data-only, but no success. used
pg_restore -v -d libval_development
with no options, but it's hanging on ****_rankings again
UPDATE 11:00: so it seems to be working. it seems the data for that table really takes 30 minutes or more. i know this also because i started a pg_dump separately on the imac and it also hung on the same table, and took around 20 minutes. it seems, if you specify the options on pg_dump, then your pg_restore doesn't need any of those options.
UPdATE: 11:55: that didnt work.
also from the log files, realizing that db:drop and db:create obviate the need for -c and -C options in pg_restore. these commands fail; but then the database connects to the named db anyway, as in:
pg_restore: connecting to database for restore pg_restore: dropping DATABASE libval_development pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 3586; 1262 50803 DATABASE libval_development allen pg_restore: [archiver (db)] could not execute query: ERROR: cannot drop the currently open database Command was: DROP DATABASE libval_development; pg_restore: creating DATABASE libval_development pg_restore: [archiver (db)] could not execute query: ERROR: database "libval_development" already exists Command was: CREATE DATABASE libval_development WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.... pg_restore: connecting to new database "libval_development" pg_restore: creating SCHEMA public pg_restore: [archiver (db)] Error from TOC entry 5; 2615 2200 SCHEMA public allen pg_restore: [archiver (db)] could not execute query: ERROR: schema "public" already exists Command was: CREATE SCHEMA public;
so i now tried the following: rake db:drop; rake db:create. BUT DO NOT migrate. the theory is that the pg_restore, with clean and create, will create the proper associations. but if this works, what then do i do with the migrations?
UPDATE 12:28. ok that finally worked. and the best part is that my schema_migrations are already run and populated. for some reason i thought the migrations are a rails/activerecord thing; but i guess every migration is translated into the sql as a schema change, and so when you restore from a db, the schema is restored along with it.