Wenn es sich um eine Rails-App handelt, können Sie mit dem folgenden Skript Ihre lokale Datenbank mit dem neuesten Dump überschreiben, den Sie auf Heroku erstellt haben. Wenn Sie die Zeile mit heroku pg:backups capture
auskommentieren, generiert das Skript vor dem Herunterladen auf Ihrem Computer einen neuen Snapshot auf Heroku.
Beachten Sie, dass Sie das Skript nicht bearbeiten müssen, da es die gesamte Konfiguration aus Ihrer Datei "database.yml" liest.
#!/usr/bin/env ruby
require_relative '../config/environment'
# Uncomment the line below if you want to generate a new snapshot of the
# Heroku production database before downloading it to the local machine
# `heroku pg:backups capture`
database_dump_file_pathname = Tempfile.new('latest.dump').path
`heroku pg:backups:download --output #{database_dump_file_pathname}`
# Get database config fom database.yml file
database_config = YAML::load_file(Rails.root.join('config', 'database.yml'))
database_name = database_config['development']['database']
database_username = database_config['development']['username']
database_password = database_config['development']['password']
# Overwrite local database with dump
cmd_line_arguments = [
'--verbose',
'--clean',
'--no-acl',
'--no-owner',
'--host localhost',
"-U #{database_username}",
"-d #{database_name}",
database_dump_file_pathname
].join(' ')
`PGPASSWORD=#{database_password} pg_restore #{cmd_line_arguments}`
Siehe die Heroku docs on downloading DB backups für Details.
Vielleicht [ 'pg_dump'] (http:// www.postgresql.org/docs/current/static/app-pgdump.html) und ['pg_restore'] (http://www.postgresql.org/docs/current/static/app-pgrestore.html)? –