Database file information not saved when downloaded back from Heroku to my PC - heroku

I am doing a Discord.py bot and my bot needs a database to store guilds, members and stuff. I uploaded my files (a created database file too) with git to Heroku and ran my bot. When people join Discord server or something, it has to record that to the database.
When I downloaded all my files back from Heroku to my computer with heroku git:clone -a <name> I see that my database is still empty, even though a member has joined. When I run my bot on my computer directly, database works fine. Why? Does Heroku even update files when my code says so? Maybe I misunderstood something?

Maybe I misunderstood something?
Yes. You deploy code to heroku by pushing it to its git repo. That's when your blank/default database file is. When heroku starts a dyno, it essentially copies the files from the git repo into the filesystem on the new dyno. As your app works, it can read and write the files on the dyno. The important points are:
Writes to that dyno-local file are not propagated back to git.
The dyno filesystem is ephemeral. When your dyno shuts down, the files are gone and all the changes are gone with them.
If you want a persisted database that can survive dyno restarts, you should use an external database instead of a local file. For example, a Postgres add-on.

Related

Keep data after Heroku dyno restart

I have a twitter bot hosted at Heroku, and once a day the server reboots. I have a text file that is constantly being modified, and when the server is restarted the changes in that file are lost. Does anyone know how to keep that file updated when the server is restarted?
Yes,you have to pay heroku for dynos : https://devcenter.heroku.com/articles/dynos
Or you can always choose to deploy it somewhere else
Heroku file system is ephemeral and gets wiped out at every restart.
A solution (if you want to keep using Heroku) is to use an external service to persist your data:
Amazon S3, see Heroku article
Github, an easy and free option if you need to perform simple get/put, see an example
A database (Atlas MongoDB has a free tier which can be used in cases like yours)

Is there a way to access files that are created by a code on heroku

I have a discord bot that saves JSON files on the same directory he is in so it could work on more than one server without colliding (he saves variables that are not important to the question) .
I finished my code and I uploaded it to heroku for hosting. The thing is , when I ran the code from my pc I could see the files that were being created for each server for testing but now I don't know how to reach them.
Is there a way to check all the files I have in heroku?
(when I mean all, I mean also the JSON files that were created from the bot itself)
side not:
You can do heroku run bash -a APPNAME but it still doesn't let me see the files that were made in the dyno or directory.
On top of that, if someone has another good hosting site(preferred free) which doesn't use a ephemeral filesystem, that would be great if you can comment them down bellow.
(or if you have a way to save the files before the dyno deletes them)
What you are searching for in Heroku is called Heroku Exec (SSH Tunneling) which you can use to SSH into running dynos for debugging purposes.

discord.py how to make a JSON file work on Heroku

When I host the bot using Heroku it no longer calculates the JSON files (even if it makes them work they do not appear) and when I restart it is as if nothing had happened and reset everything.
How can I do?
Heroku does not store changes made to files. Heroku dynos restart every once in a while, and that is when data is lost; redeploying the app can also cause the data to be lost. Using a third-party database, such as MongoDB is recommended.

Can I recover data in Heroku

I have a simple app, that stores some files in a node Heroku app.
I didn't know it, but every day the Heroku server is restarted and just the GitHub files survive. My ignored files not.
I know the date when I store those files in my app. Can I recover the Heroku App from that Day?.

Making change to Heroku server

I inherited an app, and while I intend to redeploy everything correctly shortly with a host of other changes, a client of mine wants new branding up quickly on a Heroku server.
I access the server this way:
heroku run bash --app APPNAME
and I pulled down the file via wget and put it into a static files directory.
However, after doing this, the change is not reflected live. Is there anyway to make a temporary change like this without a full redeploy?
File systems on Heroku are ephemeral - the files get deleted and there is no persistence.
The Heroku filesystem is ephemeral - that means that any changes to
the filesystem whilst the dyno is running only last until that dyno is
shut down or restarted. Each dyno boots with a clean copy of the
filesystem from the most recent deploy. This is similar to how many
container based systems, such as Docker, operate.
Why Are My Files Deleted - Heroku

Resources