You have something known as DATABASE_URL, which has to be used in the backup command. To find your database url, run the following command:
heroku pg === HEROKU_POSTGRESQL_JUPITER_URL Plan: Hobby-dev Status: Available Connections: 1/20 PG Version: 10.15 Created: 2018-12-16 08:57 UTC Data Size: 12.9 MB Tables: 39 Rows: 4751/10000 (In compliance) Fork/Follow: Unsupported Rollback: Unsupported Continuous Protection: Off Add-on: postgresql-tapered-53472
Now run the command to create the backup:
$ heroku pg:backups:capture HEROKU_POSTGRESQL_JUPITER_URL Starting backup of postgresql-copred-72... 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 JUPITER to b007... done
Now, download the backup to local folder:
$ heroku pg:backups:download Getting backup from ⬢ mysterious-boco-302564... done, #7 Downloading latest.dump... ████████████████████████▏ 100% 00:00 291.55KB
The backup has been created in the current directory with the name latest.dump.
Reference: Heroku doku
To restore a backup, use the restore command:
$ heroku pg:backups:restore b101 DATABASE_URL --app sushi
This will restore backup id
b101 to the specified database URL in the app
sushi. Note: you can omit the backup id and the target database to restore the latest backup to
DATABASE_URL, otherwise both backup id and target database must be provided.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.