View contents of PostgreSQL backup - postgresql

I am running scheduled backups on my Heroku application (rails 4). I downloaded the backup that ran last night and I'd like to view the contents of the file. When I open it in textedit, I can see the tables but then it's just a mix of characters and letters.
I have scheduled backups running every evening on my Heroku PG db so I just had to download the backup from the previous day. To download the backup I ran:
heroku pg:backups public-url --app foobar
I then visited the AWS S3 link provided by Heroku and downloaded the file onto my computer.
How would I go about either viewing the contents of the backup in terminal or any other GUI without restoring the backup into my Heroku application?

Related

Docker & Postgres - Rename database & remove old one

I have my Gitlab CI running with Symfony, I have fixtures loaded and I want to load them in a buffer dabatase, and then to move them to the real database.
I've seen this thread: Docker - How can run the psql command in the postgres container?, but I would like to have an automatic script which:
delete my real database
rename my buffer database to the real database's name
Is it possible using Docker & Gitlab CI to automate such commands? I am using pg_dump for now, but it's long an not easy to use, I just want to replace a DB with an other DB.

Heroku: Can I schedule PostgreSQL backups using the Scheduler add-on (maybe with pgbackups)?

I have a small app, and I run backups manually using heroku pgbackups:capture on my dev machine.
I'd like to use the Heroku Scheduler send these backups to my own S3 bucket.
The thing is: pg_dump is not an available on Heroku boxes, and heroku pgbackups:capture is a local CLI command, also not available.
Is there another way to achieve this using Scheduler?

heroku postgres : creating a database off of a backup creates a empty database

We're having trouble with the heroku fork command so are manually trying to create a staging environment. I tried creating a new database off of a backup from our prod db but the created db has no rows and is only 6.4MB. The actual backup is 15.7 GB.
I did this via the web console clicking "restore".
Whats the right way to do this?
From the command line, you want to do:
heroku pgbackups:restore DATABASE -a example-staging `heroku pgbackups:url -a example`
We use this command every few days, whenever we want the staging database to be replaced with the production database. This comes from: https://devcenter.heroku.com/articles/migrate-heroku-postgres-with-pgbackups#transfer-to-target-database

how to take heroku postgress DB backup on remote location?

hi I take backup of my heroku database using PGBackups but its provide me backup on there pre define places .now I wont to take that backup on my remote location folder on S3 or some other remote storage.
how can we do that periodically like every week or month it's own/automatically.
my app on Ruby on Rails help me to achieve this.
The latest backup is always available to you by entering heroku pgbackups:url. So, set up a cron job or the equivalent that fetches that URL once a week or once a day.
You could write a rake or Ruby script and call it with Heroku Scheduler (a free addon), or use a different remote machine to pull the backup, or do a shell script and:
curl -O `heroku pgbackups:url`
Here is a Gem that appears to do what you want: https://coderwall.com/p/w4wpvw

Copy database between Heroku apps using multiple URLs

Our database on Heroku has grown to size which requies three pgbackups URLs to download. I know how to download this database backup to local computer, merge the parts together and do restore, but what to do if I want to copy database from one Heroku app to other?
If you want to copy from one application from another you should be able to fork your database across applications. You can do this with:
heroku addons:add heroku-postgresql:crane --fork HEROKU_POSTGRESQL_SOURCE_OF_OLD_DB_AS_URL --app newapphere