...
To verify that we have scheduled backups, run
heroku pg:backups:schedules --app scihist-digicoll-production
, to see that we have a 2AM backup ever night.List what backups exist by running
heroku pg:backups -a scihist-digicoll-production
Note the first section is “backups” (which may scroll off screen), and the first column is a backup ID, such asa189
.With the backup ID, you can restore production to a past backup (eg id
a189
), withheroku pg:backups:restore a189 -a scihist-digicoll-production
Warning: this will overwrite current production data, with the restored backup!
Warning: see note below re:
--extensions
.
Maybe instead you want to restore a production backup to staging, to just look at the data, without actually (yet?) restoring to and overwriting current production? You can do this too:
heroku pg:backups:restore scihist-digicoll-production::a189 -a scihist-digicoll-staging
💡 Warning: the above command will may fail if the database you are restoring from has extensions installed in the
public
schema, subsequent to some changes in how Heroku works with extensions). There is a workaround: using theextensions
flag as in the example below allows you topg:restore
from a database that has extensions inpublic
(like the current production DB , as of before Sept 2022)
Code Block |
---|
heroku pg:backups:restore scihist-digicoll-production::a661 DATABASE_URL \ --extensions 'public.pg_stat_statements,public.pgcrypto' \ --app scihist-digicoll-staging |
...