Tuesday, October 19, 2021

download db from heroku

 If you are using heroku with postgres, here is how to download dthe dump


user@pc MINGW64 ~/tmp/jdl2 (main)
$ heroku pg:backups:capture
Starting backup of postgresql-reticulated-07948... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
Use heroku pg:backups:info to check progress.
Stop a running backup with heroku pg:backups:cancel.

Backing up DATABASE to b001... done
user@pc MINGW64 ~/tmp/jdl2 (main)
$ heroku pg:backups:download
Getting backup from hamta... fetching url of #1
Getting backup from hamta... done, #1
user@pc MINGW64 ~/tmp/jdl2 (main)
$ ls -ltrh
total 1.2M
-rwxr-xr-x 1 ozkan 197609 9.9K Oct 12 10:21 mvnw*
-rwxr-xr-x 1 ozkan 197609  509 Oct 12 10:21 npmw*
-rw-r--r-- 1 ozkan 197609 1.9K Oct 15 17:34 test.jdl
..............................

-rw-r--r-- 1 ozkan 197609  62K Oct 16 15:12 pom.xml
-rw-r--r-- 1 ozkan 197609   24 Oct 19 21:33 system.properties
drwxr-xr-x 1 ozkan 197609    0 Oct 19 21:36 node_modules/
-rw-r--r-- 1 ozkan 197609 1.5M Oct 19 21:36 package-lock.json
drwxr-xr-x 1 ozkan 197609    0 Oct 19 21:37 target/
-rw-r--r-- 1 ozkan 197609  31K Oct 19 21:43 latest.dump

how to restore

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump

No comments: