Skip to main content

Sync local sql dump to Hatchbox database

Piping

1. through

Download file from Heroku

YouIf canyou use pg_restore and pipe its output directlyneed to the psql command that connects todownload the remotedatabase PostgreSQLfrom database.

heroku,
    do
  1. Command syntax:this:

    heroku pg_restorepg:backups:capture /path/to/local/dumpfile--app |example-app
    psqlheroku "host=remote_serverpg:backups:download port=5432--app dbname=remote_db_name user=remote_db_user"example-app

    Replace

    2. theSend placeholders with your specific details.

This methods assume that:

  • The remote PostgreSQL port is 5432 (replace as needed).
  • remote_db_name is the name of the remote database you wantfile to restoreserver into.
  • scp 
  • remote_db_user is the username you use to connect to the remote database.
  • ./path/to/local/dumpfile is the path to your local PostgreSQL latest.dump file.
  • deploy@13.51.249.208:/home/deploy

3.

Make sure the remote PostgreSQL server is configured to allow connections from your IP and that you have the necessary privileges to restore the database.

Also,Load the dump file shouldinto the hatchbox database

Find the database information in the https://app.hatchbox.io/database_clusters page on Hatchbox.

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U user_6353c004a1da -d db_94eeb162733f latest.dump

This will result in some errors but these can most likely be compatibleignored withsince thethey versionare of PostgreSQL on the remote serverrelated to avoidheroku issuestables. during restoration.