How do I transfer production database to staging on Heroku using pgbackups? Getting error

后端 未结 12 2170
刺人心
刺人心 2021-01-30 03:13

On Heroku, I am trying to copy the production database into my staging app using the pgbackups addon. I followed the instructions on the addon page: https://devcenter.heroku.com

12条回答
  •  生来不讨喜
    2021-01-30 03:40

    Update for mid-2017 (stealing from Takehiro Mouri's answer - simplify the DATABSE_NAME part)

    Update for mid-2015...

    The pgbackups add-on has been deprecated. No more pgbackups:transfer.

    To copy a database from yourapp to yourapp_staging:

    # turn off the web dynos in staging
    heroku maintenance:on -a yourapp-staging
    
    # if you have non-web-dynos, do them too
    heroku ps:scale worker=0 -a yourapp-staging
    
    # backup the staging database if you are paranoid like me (optional)
    heroku pg:backups capture -a yourapp-staging
    
    # execute the copy
    heroku pg:copy your-app::DATABASE_URL DATABASE_URL -a yourapp-staging
    

    Then when it's complete, turn staging back on:

    # this is if you have workers, change '1' to whatever
    heroku ps:scale worker=1 -a yourapp-staging
    
    heroku maintenance:off -a yourapp-staging
    

    (source: https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases#upgrade-with-pg-copy-default)

提交回复
热议问题