I created a nice little Rake task to backup our Mysql database on ClearDB to a remote Google storage bucket. Works great locally but running it on Heroku I get this error:
sh: mysqldump: not found
Of course, Heroku doesn't have mysqldump, how silly of me, but is there any way to do this?
The command I'm using is something like this:
system "mysqldump -h host.cleardb.com -u user -p'password' --single-transaction database | gz > #{backup_directory}/#{file_name}"
Of course gzip doesn't exist either on Heroku.
I know there are a couple of gems to backup PostgreSQL databases but I haven't seen anything for Mysql.
This is for a Rails 3.2 app.
Any ideas would be appreciated.
I'd say your best option would be a custom build pack that adds the mysql binaries that you need.
https://devcenter.heroku.com/articles/buildpacks
Related
My project is again live no problems whatsoever, but the database is empty.
I am either trying to restore an old backup to the new Postgres instance or upload a backup from my local disk.
I tried to do pg:restore but I don’t know where to grab the backup (from the free Heroku tier).
I got the answer I was looking for by going into some of the most hidden help articles in heroku.
https://help.heroku.com/QG1W7LIJ/how-do-i-restore-a-partial-backup-or-single-table-to-heroku-postgres
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U YOUR_USERNAME-d CONNECTION_URL mydb.dump
Had to recreate the backup from the local imported database but at the end it worked flawlessly.
I am having a QA instance which contains a very limited data(approx 30-35 MB) it contains images etc, thumbnails hence cannot put them into seed.
I have a private repo at github(synced with heroku) which contains a .dump file say abc.dump file and I want to run my test cases from travis, in the before script I will be restoring this dump.
I would like to know how to import this dump to heroku although this is available at heroku bash as well. I looked into the documentation here they say make it asseccible through http somewhere. I am trying using the pg_restore commands using the database username, passwords available at the application database overview available through UI, but not working.
Can someone suggest me a good way out to simply restore by not making my database public ?
Also. how often the database user/password is changed at heroku ?
As travis would be having access to abc.dump beforehand it can perform basic pg_restore function of postgresql.
PGPASSWORD=<PASSWORD> pg_restore --verbose --clean --no-acl --no-owner -h <PG_HOSTNAME> -U <PG_USER> -d <PG_DATABASE_NAME> -p <PG_PORT_NO> <DUMP_FILE>.dump
The above details for the heroku database hostname, user, pass, port etc. can be fount easily using :-
heroku pg:credentials DATABASE --app application_name
I recently made a mistake by rolling back my database too far on my localhost and removed all the data from within the databases I've had. I did migrate the databases so they would return but they still were cleaned out.
Asking around what to do next, I was told that I should backup the database on Heroku (which has all the current information) and pull it onto my localhost. If this is the correct action to take, then I am still facing a problem. When I type:
heroku pg:pull DATABASE_URL mylocaldb --app (my_app_name) it returns an error of:
sh: createdb: command not found
!
! Unable to create new local database. Ensure your local Postgres is
working and try again.
I do not have the best understanding of databases as I am newer; however, I have downloaded sql on my local machine. All of the commands I input are in the regular console and not the psql terminal.
If anyone has any knowledge or can help me, I would greatly appreciate it. Thank you so much!
Joe
Edit: If you do have another method/solution, please let me know. I cannot update my application until I have this done so I do not lose my information.
I would try using backup/restore:
heroku pg:backups --app MYAPPNAME capture
curl -o latest.dump `heroku pg:backups --app MYAPPNAME public-url`
as (almost) documented at
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Note the strange placement of --app MYAPPNAME. It needs to go immediately after the heroku sub-command and before any other arguments.
I need to use some PostgreSQL proprietary features such as rules and triggers for table partitioning. As long as I know, these kind of features cannot be dump to schema.rb so I have changed my schema_format configuration parameter to :sql.
Now, when I try to load rake db:structure:load to load the generated structure.sql into the heroku database, it fails saying: sh: psql: not found
How can I do it?
You can use pg:psql to run the script from your development machine against the database:
cd your-rails-project
heroku pg:psql -a your-app-name <db/structure.sql
Just make sure that the branch you have checked out locally is the same as the one you have deployed.
With the taps gem it was possible to do:
heroku db:pull -f '^(?!requests).*' --app AppName --confirm AppName"
which would transfer the schema and all tables and indexes except for those of the requests table would be left in the production database.
Is there any option to do this yet with pg:transfer? I can't see one.
You can use the full pg_dump command on your local computer against your remote heroku postgres database. pg_dump has several options, including selectively dumping tables.
See http://www.postgresql.org/docs/current/static/app-pgdump.html for the complete information on pg_dump