Download sqlite database from Heroku

◇◆丶佛笑我妖孽 提交于 2021-01-28 23:36:47

问题


I have a worker running python script every 2 hour on Heroku.

The problem is each time I 'pull' the changes from git.

There is no changes at all for the sqlite3 database.

But I am sure the program is running and the database has changed by looking at the log file.

heroku log

How to retrieve the .db file then ?


回答1:


It sounds like you have a little misconception. Heroku's git support is effectively one-way; you can use it to push new code to be run on the server, but you can't use it to copy files from Heroku back to your local tree.

Unfortunately it looks like there's not a good easy way to copy a file from your app to your local machine; you can use heroku run console to get a bash shell, and then scp a file out, but you're "pushing" it out of Heroku, and thus run can only copy to things with valid IP addresses.

If you're really using sqlite for your app's storage, though, you're going to run into a bigger problem. The filesystem for your app on Heroku is ephemeral, in that changes you make can be wiped out at any time. Heroku will delete your app's local storage and start over fresh whenever it wants to.

The right way to do it is use Heroku's built-in Postgres support and store your application's data there. Not only will it persist, but you'll be able to access it directly using the Postgres command-line tools.




回答2:


Accessing the heroku console can now be done with:

heroku run bash

then i downloaded the linux gdrive application and ran in locally in the folder to upload my file to google drive. https://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line/ (skip step 4 and run with ./ like this ./gdrive upload my_file.txt

the other suggestion of heroku run console did not work for me (running a python flask app)



来源:https://stackoverflow.com/questions/27663075/download-sqlite-database-from-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!